[20180306]資料塊檢查和2.txt

lfree發表於2018-03-06

[20180306]資料塊檢查和2.txt

--//昨天測試修改檢查和偏移為0x0(偏移在16,17位元組),在修改前面的15位元組為0,一般資料塊可以透過檢查.
--//連結:http://blog.itpub.net/267265/viewspace-2151524/

--//今天測試如果資料塊在system表空間的情況下會是否可行.

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 system.deptx tablespace system as select * from dept;
Table created.

SCOTT@book> select rowid,deptx.* from  system.deptx where deptno=10;
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAWGYAABAAAAl5AAA         10 ACCOUNTING     NEW YORK

SCOTT@book> @ &r/rowid AAAWGYAABAAAAl5AAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     90520          1       2425          0   0x400979           1,2425               alter system dump datafile 1 block 2425

BBED> sum dba 1,2425
Check value for File 1, Block 2425:
current = 0x41f3, required = 0x41f3

--//當前檢查和41f3.

2.關閉資料庫修改看看:
SYS@book> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

--//修改對應資訊:

BBED> p chkval_kcbh
ub2 chkval_kcbh                             @16       0x41f3

BBED> p flg_kcbh
ub1 flg_kcbh                                @15       0x04 (KCBHFCKV)

BBED> assign  kcbh.flg_kcbh=0x0
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub1 flg_kcbh                                @15       0x00 (NONE)

BBED> assign  kcbh.chkval_kcbh=0x0
ub2 chkval_kcbh                             @16       0x0000

BBED> sum dba 1,2425
Check value for File 1, Block 2425:
current = 0x0000, required = 0x0000

3.啟動資料庫看看:
SYS@book> startup
ORACLE instance started.
Total System Global Area  638910464 bytes
Fixed Size                  2255832 bytes
Variable Size             201327656 bytes
Database Buffers          427819008 bytes
Redo Buffers                7507968 bytes
Database mounted.
Database opened.

SYS@book> select rowid,deptx.* from  system.deptx where deptno=10;
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAWGYAABAAAAl5AAA         10 ACCOUNTING     NEW YORK

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

BBED> set dba 1,2425
        DBA             0x00400979 (4196729 1,2425)

BBED> sum
Check value for File 1, Block 2425:
current = 0x0000, required = 0x0000

--//一樣可行.看來理解存在問題.算一下這個時候檢查和是多少.

BBED> set dba 1,2425
        DBA             0x00400979 (4196729 1,2425)

BBED> assign  kcbh.flg_kcbh=0x4
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub1 flg_kcbh                                @15       0x04 (KCBHFCKV)

BBED> sum
Check value for File 1, Block 2425:
current = 0x0000, required = 0x41f3

--//可以看出bbed的檢查和演算法,如果kcbh.flg_kcbh=0x0,估計跳過檢查和計算.
--//2425*8192 = 19865600

$ xxd -c16 -g 2 -s 19865600 -l 8192 /mnt/ramdisk/book/system01.dbf | cut -c10-50 | xor.sh
..
xor result: F345

--//可以發現跳過了檢查和檢查.

BBED> set dba 1,2425
        DBA             0x00400979 (4196729 1,2425)

BBED> assign  kcbh.flg_kcbh=0x4
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
ub1 flg_kcbh                                @15       0x04 (KCBHFCKV)

BBED> assign  kcbh.chkval_kcbh=0x41f3
ub2 chkval_kcbh                             @16       0x41f3

--//修改回來.

$ xxd -c16 -g 2 -s 19865600 -l 8192 /mnt/ramdisk/book/system01.dbf | cut -c10-50 | xor.sh
...
xor result: 0

--//這樣就正確了.也許對檔案頭不行,不測試了.
--//xor.sh指令碼參考連結:http://blog.itpub.net/267265/viewspace-2134945/

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

相關文章