[20180306]数据块检查和.txt

[20180306]数据块检查和.txt

--//如果数据块检查和不对,数据库无法读取相应块,会报错.
--//检查和位于块偏移16字节处.
ub1 flg_kcbh                            @15
ub2 chkval_kcbh                         @16
--//实际上如果设置flg_kcbh,chkval_kcbh=0,一般数据块是可以跳过的.测试看看.
--//注意:要关闭dg,不然会自动修复.

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> create table deptx tablespace tea as select * from dept;
Table created.

SCOTT@book> select rowid,deptx.* from deptx;
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAWGWAAGAAAACBAAA         10 ACCOUNTING     NEW YORK
AAAWGWAAGAAAACBAAB         20 RESEARCH       DALLAS
AAAWGWAAGAAAACBAAC         30 SALES          CHICAGO
AAAWGWAAGAAAACBAAD         40 OPERATIONS     BOSTON

SCOTT@book> @ &r/rowid AAAWGWAAGAAAACBAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     90518          6        129          0  0x1800081           6,129                alter system dump datafile 6 block 129 ;

SCOTT@book> alter system checkpoint ;
System altered.

SCOTT@book> alter system flush buffer_cache;
System altered.

2.使用bbed修改块6,129.

SCOTT@book> @ &r/bbvi 6 129
BVI_COMMAND
----------------------------------------------------------------------------------------------------
bvi -b 1056768 -s 8192 /mnt/ramdisk/book/tea01.dbf

--//使用bvi修改ACCOUNTING为A12OUNTING.

BBED> set dba   6,129
        DBA             0x01800081 (25165953 6,129)

BBED> x   /rncc *kdbr[0]
rowdata[66]                                 @8162
-----------
flag@8162: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8163: 0x00
cols@8164:    3

col    0[2] @8165: 10
col   1[10] @8168: A12OUNTING
col    2[8] @8179: NEW YORK

BBED> sum
Check value for File 6, Block 129:
current = 0x49c5, required = 0x38b7
--//可以发现现在已经不一致.

SCOTT@book> select rowid,deptx.* from deptx;
select rowid,deptx.* from deptx
                          *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 129)
ORA-01110: data file 6: '/mnt/ramdisk/book/tea01.dbf'

--//报ORA-01578错误.

3.清除flg_kcbh,chkval_kcbh看看.
SCOTT@book> alter system flush buffer_cache;
System altered.

BBED> assign  kcbh.chkval_kcbh=0x0
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub2 chkval_kcbh                             @16       0x0000

BBED> assign  kcbh.flg_kcbh=0x0
ub1 flg_kcbh                                @15       0x00 (NONE)

BBED> sum
Check value for File 6, Block 129:
current = 0x0000, required = 0x0000

--//这样就ok了.

SCOTT@book> select rowid,deptx.* from deptx;
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAWGWAAGAAAACBAAA         10 A12OUNTING     NEW YORK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AAAWGWAAGAAAACBAAB         20 RESEARCH       DALLAS
AAAWGWAAGAAAACBAAC         30 SALES          CHICAGO
AAAWGWAAGAAAACBAAD         40 OPERATIONS     BOSTON

--//注意看下划线,以后没有bbed,对于一般的数据块可以直接设置块偏移量15,16,17字节为0x0,就ok了.
--//但是对系统表空间是无效的(没测试).缺省数据库的参数_db_always_check_system_ts=true.

SYS@book> @ &r/hide _db_always_check_system_ts
NAME                       DESCRIPTION                                                   DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
-------------------------- ------------------------------------------------------------- ------------- ------------- ------------
_db_always_check_system_ts Always perform block check and checksum for System tablespace TRUE          TRUE          TRUE

上一篇:Google X:做一件事需要三个要素


下一篇:[Google Guava] 11-事件总线