[20150522]bbed与数据块检查和.txt
--我现在基本拿bbed学习,基本是拿bbed查看,而使用bvi修改数据.我感觉这种方便1写.
--实际上使用bbed的好处就是修改数据块检查和不一致,而使用bbed修改很简单仅仅需要执行sum apply就ok了.
--对比dbv与bbed确定检查和位置.
1.建立测试环境:
SCOTT@test> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx 10.2.0.4.0 Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
SCOTT@test> select rowid,deptx.* from deptx;
ROWID DEPTNO DNAME LOC
------------------ ------------ -------------- -------------
AAAO1FAAGAAAAAKAAA 10 ACCOUNTING NEW YORK
AAAO1FAAGAAAAAKAAB 20 RESEARCH DALLAS
AAAO1FAAGAAAAAKAAC 30 SALES CHICAGO
AAAO1FAAGAAAAAKAAD 40 OPERATIONS BOSTON
SCOTT@test> @ &r/lookup_rowid AAAO1FAAGAAAAAKAAA
OBJECT FILE BLOCK ROW DBA TEXT
------------ ------------ ------------ ------------ -------------------- ----------------------------------------
60741 6 10 0 6,10 alter system dump datafile 6 block 10 ;
SCOTT@test> alter system checkpoint;
System altered.
SCOTT@test> alter system flush buffer_cache;
System altered.
$ bvi -b 81920 -s 8192 /mnt/ramdisk/test/mssm01.dbf
--修改.
YORK=>york
--说明:bvi修改很简单选择R,替换里面的K->k. 前面的参数-b 表示开始偏移量,10*8192=81920. -s表示显示大小.
--这样就人为的破坏了检查和.
BBED> set dba 6,10
DBA 0x0180000a (25165834 6,10)
BBED> sum;
Check value for File 6, Block 10:
current = 0x893e, required = 0x893e
--出现一个奇怪的情况,检查和是正确的.说明checksum的算法很简单,这样修改竟然会重合!!!!
$ bvi -b 81920 -s 8192 /mnt/ramdisk/test/mssm01.dbf
--修改.
YORK=>aaaa
BBED> set dba 6,10
DBA 0x0180000a (25165834 6,10)
BBED> sum
Check value for File 6, Block 10:
current = 0x893e, required = 0x8d35
2.开始测试:
SCOTT@test> alter system flush buffer_cache;
System altered.
SCOTT@test> select rowid,deptx.* from deptx;
select rowid,deptx.* from deptx
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 10)
ORA-01110: data file 6: '/mnt/ramdisk/test/mssm01.dbf'
--我所关注两个: 1.检查和位置 2.如果没有bbed,如何确定检查和.
$ dbv file=/mnt/ramdisk/test/mssm01.dbf
DBVERIFY: Release 10.2.0.4.0 - Production on Fri May 22 11:33:49 2015
Copyright (c) 1982, 2007, Oracle. All rights reserved.
DBVERIFY - Verification starting : FILE = /mnt/ramdisk/test/mssm01.dbf
Page 10 is marked corrupt
Corrupt block relative dba: 0x0180000a (file 6, block 10)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x0180000a
last change scn: 0x0002.f445ace5 seq: 0x2 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xace50602
check value in block header: 0x893e
computed block checksum: 0x40b
DBVERIFY - Verification complete
Total Pages Examined : 2048
Total Pages Processed (Data) : 1
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 10
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 2036
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Highest block SCN : 4098132609 (2.4098132609)
3.从以上观察:
--数据块记录的检查和是0x893e,目前真正正确的是0x8d35
--而dbv提示的是:
check value in block header: 0x893e
computed block checksum: 0x40b
--很明显块checksum不是 0x40b,有时候觉得oracle的设计不人性化,既然知道不对,为什么不给出当前正确的值,而是给出一个computed block checksum: 0x40b.
-- 当然算法很简单,异或就可以了.
893e => 1000 1001 0011 1101
40b => 0000 0100 0000 0110
----------------------------
1000 1101 0011 1011 => 8d35
--查询块:可以发现偏移是16,注意查询是倒过来 3e89.使用bbed也可以确定.
BBED> print chkval_kcbh
ub2 chkval_kcbh @16 0x893e
BBED> sum apply
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Check value for File 6, Block 10:
current = 0x8d35, required = 0x8d35
BBED> print chkval_kcbh
ub2 chkval_kcbh @16 0x8d35
SCOTT@test> alter system flush buffer_cache;
System altered.
SCOTT@test> select rowid,deptx.* from deptx;
ROWID DEPTNO DNAME LOC
------------------ ------------ -------------- -------------
AAAO1FAAGAAAAAKAAA 10 ACCOUNTING NEW aaaa
AAAO1FAAGAAAAAKAAB 20 RESEARCH DALLAS
AAAO1FAAGAAAAAKAAC 30 SALES CHICAGO
AAAO1FAAGAAAAAKAAD 40 OPERATIONS BOSTON
--可以知道使用dbv确定也很简单,做一个异或就ok了.