[20180306]数据块检查和2.txt

[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/

上一篇:假期前的数据库检查之主动优化


下一篇:罗明雄:大数据金融运营模式分析