[20180306]資料塊檢查和.txt

lfree發表於2018-03-05

[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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2151524/,如需轉載,請註明出處,否則將追究法律責任。

相關文章