[20160531]windows下bbed修复corrupt数据块.txt
--昨天别人的问题,使用windows下的bbed修复corrupt数据块报错.我自己也重复测试看看:
--bbed在windows的安装看:
http://blog.itpub.net/267265/viewspace-2109019/
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 dept2 tablespace tea as select * from dept ;
Table created.
SCOTT@book> select ora_rowscn,rowid,dept2.* from dept2 ;
ORA_ROWSCN ROWID DEPTNO DNAME LOC
------------ ------------------ ------------ -------------- -------------
13238134154 AAAW9NAAHAAAACDAAA 10 ACCOUNTING NEW YORK
13238134154 AAAW9NAAHAAAACDAAB 20 RESEARCH DALLAS
13238134154 AAAW9NAAHAAAACDAAC 30 SALES CHICAGO
13238134154 AAAW9NAAHAAAACDAAD 40 OPERATIONS BOSTON
SCOTT@book> @ &r/rowid AAAW9NAAHAAAACDAAA
OBJECT FILE BLOCK ROW DBA TEXT
------------ ------------ ------------ ------------ -------------------- ----------------------------------------
94029 7 131 0 7,131 alter system dump datafile 7 block 131 ;
SCOTT@book> alter system checkpoint;
System altered.
SCOTT@book> select * from v$dbfile where file#=7;
FILE# NAME
------------ ----------------------------------------
7 /mnt/ramdisk/book/tea01.dbf
2.拷贝数据文件到windows:
BBED> set dba 7,132
DBA 0x01c00084 (29360260 7,132)
--//注意windwos下block+1.
BBED> p kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0x06
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x01c00083
ub4 bas_kcbh @8 0x150de58c
ub2 wrp_kcbh @12 0x0003
ub1 seq_kcbh @14 0x02
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0x443c
ub2 spare3_kcbh @18 0x0000
BBED> p tailchk
ub4 tailchk @8188 0xe58c0602
按照文档的说明:
seq_kcbh 表示Sequence number,incremented for every change made to the block at the same SCN.
tailchk 看文档 包括 SCN base+type+SCN seq.
BBED> corrupt
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Block marked media corrupt.
BBED> sum apply
Check value for File 7, Block 132:
current = 0xf135, required = 0xf135
BBED> verify
DBVERIFY - Verification starting
FILE = R:\tea01.dbf
BLOCK = 131
Block 131 is corrupt
***
Corrupt block relative dba: 0x01c00083 (file 0, block 131)
Bad header found during verification
Data in bad block -
type: 6 format: 2 rdba: 0x01c00084
last change scn: 0x0000.00000000 seq: 0xff flg: 0x04
consistency value in tail: 0x000006ff
check value in block header: 0xf135, computed block checksum: 0x0
spare1: 0x0, spare2: 0x0, spare3: 0x0
***
--//verify 报错.
BBED> p seq_kcbh
ub1 seq_kcbh @14 0xff
BBED> p tailchk
ub4 tailchk @8188 0x000006ff
--//修复,正常这样修复很简单,就是设置seq_kcbh=0x01,tailchk=0x00000601.
BBED> assign seq_kcbh=0x01
ub1 seq_kcbh @14 0x01
BBED> assign tailchk=0x00000601
ub4 tailchk @8188 0x00000601
BBED> sum apply
Check value for File 7, Block 132:
current = 0xf135, required = 0xf135
BBED> verify
DBVERIFY - Verification starting
FILE = R:\tea01.dbf
BLOCK = 131
Block 131 is corrupt
***
Corrupt block relative dba: 0x01c00083 (file 0, block 131)
Bad header found during verification
Data in bad block -
type: 6 format: 2 rdba: 0x01c00084
last change scn: 0x0000.00000000 seq: 0x1 flg: 0x04
consistency value in tail: 0x00000601
check value in block header: 0xf135, computed block checksum: 0x0
spare1: 0x0, spare2: 0x0, spare3: 0x0
***
--//verify 报错.注执行上面这些在linux下已经正常修复了.
BBED> p kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0x06
ub1 frmt_kcbh @1 0x02
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x01c00084
ub4 bas_kcbh @8 0x00000000
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x01
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xf135
ub2 spare3_kcbh @18 0x0000
--//scn设置为0,不行吗?设置bas_kcbh看看:
BBED> p ktbbh.ktbbhitl[0].ktbitbas
ub4 ktbitbas @64 0x150de58a
BBED> assign kcbh.bas_kcbh=0x150de58a
ub4 bas_kcbh @8 0x150de58a
--注意tailchk要修改为0xe58a0601,前面4位来之kcbh.bas_kcbh的后4位.
BBED> sum apply
Check value for File 7, Block 132:
current = 0xe438, required = 0xe438
BBED> verify
DBVERIFY - Verification starting
FILE = R:\tea01.dbf
BLOCK = 131
Block 131 is corrupt
***
Corrupt block relative dba: 0x01c00083 (file 0, block 131)
Bad header found during verification
Data in bad block -
type: 6 format: 2 rdba: 0x01c00084
last change scn: 0x0000.150de58a seq: 0x1 flg: 0x04
consistency value in tail: 0xe58a0601
check value in block header: 0xe438, computed block checksum: 0x0
spare1: 0x0, spare2: 0x0, spare3: 0x0
***
--//依旧报错,这次仔细看发现rdba: 0x01c00084变成了偶数,我修改的块dba=7,131后面是奇数.
--//8*16+4=132,如果你看修改前的kcbh.rdba_kcbh=0x01c00083.
--//很明显在bbed下执行corrupt修改了kcbh.rdba_kcbh.
--//问题因为在windows下使用访问块时+1而导致的错误,所以讲windows下使用要小心.
BBED> p kcbh.rdba_kcbh
ub4 rdba_kcbh @4 0x01c00084
BBED> assign kcbh.rdba_kcbh=0x01c00083
ub4 rdba_kcbh @4 0x01c00083
BBED> sum apply
Check value for File 7, Block 132:
current = 0xe43f, required = 0xe43f
BBED> verify
DBVERIFY - Verification starting
FILE = R:\tea01.dbf
BLOCK = 131
DBVERIFY - Verification complete
Total Blocks Examined : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing (Index): 0
Total Blocks Empty : 0
Total Blocks Marked Corrupt : 0
Total Blocks Influx : 0
--Ok,通过,总之在windows下使用要注意.
--我一直感觉很奇怪bbed在9i下正常的,而到了10g,11g访问块都要加一个块,不知道为什么,因为32位与64位的区别吗?
--有计划找一台32位的机器测试看看.