[20160531]windows下bbed修復corrupt資料塊

lfree發表於2016-05-31

[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位的機器測試看看.

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

相關文章