有朋友資料檔案頭出現錯誤ORA-01122和ORA-01210等錯誤,資料庫無法正常open。
因為平台是win,他們找我諮詢win bbed,因為回老家電腦沒有帶,無法提供win的bbed.我通過dd部分檔案頭,然後在linux平台分析發現是該檔案的檔案頭block大量壞塊
bbed分析壞塊情況
BBED> show all FILE# 0 BLOCK# 1 OFFSET 0 DBA 0x00000000 (0 0,1) FILENAME /tmp/30.dbf BIFILE bifile.bbd LISTFILE BLOCKSIZE 8192 MODE Browse EDIT Unrecoverable IBASE Dec OBASE Dec WIDTH 80 COUNT 512 LOGFILE log.bbd SPOOL No BBED> set count 64 COUNT 64 BBED> map File: /tmp/30.dbf (0) Block: 1 Dba:0x00000000------------------------------------------------------------BBED-00400: invalid blocktype (27) BBED> d File: /tmp/30.dbf (0) Block: 1 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 03004400 bffd8a1d 0000000c acba0000 008f4500 00003455 fc020000 02040000 00000000 00008001 04000000 00000000 00000000 949400b4 94514005 <32 bytes per line> BBED> set block +1 BLOCK# 2 BBED> map File: /tmp/30.dbf (0) Block: 2 Dba:0x00000000------------------------------------------------------------BBED-00400: invalid blocktype (27) BBED> d File: /tmp/30.dbf (0) Block: 2 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 04004400 bffd8a1d 0000000c a6e00000 008f4500 00003455 fc020000 0204e81f 00000000 0000241e 05000000 00000000 00000000 11fc297f b426fe2b <32 bytes per line> BBED> set block +1 BLOCK# 3 BBED> d File: /tmp/30.dbf (0) Block: 3 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 05004400 bffd8a1d 0000000c 780a0000 008f4500 00003455 fc020000 0204e81f 00000000 0000c001 06000000 00000000 00000000 2969a0d2 d30168a2 <32 bytes per line> BBED> set block +1 BLOCK# 4 BBED> d File: /tmp/30.dbf (0) Block: 4 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 06004400 bffd8a1d 0000000c 6c5a0000 008f4500 00003455 fc020000 0204e81f 00000000 0000f81d 07000000 00000000 00000000 7b51d409 6dc7ca4d <32 bytes per line> BBED> set block +1 BLOCK# 5 BBED> d File: /tmp/30.dbf (0) Block: 5 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 07004400 bffd8a1d 0000000c c5600000 008f4500 00003455 fc020000 02040000 00000000 0000c001 08000000 00000000 00000000 14514005 25145200 <32 bytes per line> BBED> set block +1 BLOCK# 6 BBED> d File: /tmp/30.dbf (0) Block: 6 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 08004400 bffd8a1d 0000000c 60480000 008f4500 00003455 fc020000 0204e81f 00000000 0000c301 09000000 00000000 00000000 c2a1606a 7615130a <32 bytes per line> BBED> set block +1 BLOCK# 7 BBED> d File: /tmp/30.dbf (0) Block: 7 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 09004400 bffd8a1d 0000000c e3430000 008f4500 00003455 fc020000 0204e81f 00000000 00000002 0a000000 00000000 00000000 00a28a28 00a28a28 <32 bytes per line> BBED> set block +1 BLOCK# 8 BBED> d File: /tmp/30.dbf (0) Block: 8 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 0a004400 07fe8a1d 0000000c fc000000 008f4500 00003455 fc020000 0205e81f 00000000 0000f41d 00000000 00000000 00000000 ffd8ffe0 00104a46 <32 bytes per line> BBED> set block +1 BLOCK# 9 BBED> d File: /tmp/30.dbf (0) Block: 9 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 0b004400 07fe8a1d 0000000c 48da0000 008f4500 00003455 fc020000 0205e81f 00000000 0000c601 01000000 00000000 00000000 b47d69d3 7fa96a6f <32 bytes per line> BBED> set block +1 BLOCK# 10 BBED> d File: /tmp/30.dbf (0) Block: 10 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 0c004400 07fe8a1d 0000000c be0f0000 008f4500 00003455 fc020000 0205e81f 00000000 0000181d 02000000 00000000 00000000 9de3e868 4782d83a <32 bytes per line> BBED> set block +1 BLOCK# 11 BBED> d File: /tmp/30.dbf (0) Block: 11 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 0d004400 07fe8a1d 0000000c 9cd00000 008f4500 00003455 fc020000 0205e81f 00000000 0000241e 03000000 00000000 00000000 dead1259 5919e385 <32 bytes per line> BBED> set block +1 BLOCK# 12 BBED> d File: /tmp/30.dbf (0) Block: 12 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 0e004400 07fe8a1d 0000000c df450000 008f4500 00003455 fc020000 0205e81f 00000000 00004001 04000000 00000000 00000000 31d9a292 9698828a <32 bytes per line> BBED> set block +1 BLOCK# 13 BBED> d File: /tmp/30.dbf (0) Block: 13 Offsets: 0 to 63 Dba:0x00000000------------------------------------------------------------------------ 1ba20000 0f004400 07fe8a1d 0000000c 18790000 008f4500 00003455 fc020000 02050000 00000000 00000002 05000000 00000000 00000000 b93f8235 5ea063b7 <32 bytes per line>
拿block 1的rdba(04004400?倒序儲存)分析[win檔案拷貝到linux後使用bbed查看相差1 block]可以的出來block資訊為file=1, block=262148,明顯錯誤.
通過dul分析檔案頭損壞情況
Data UnLoader: 10.2.0.6.9 - Internal Only - on Tue Sep 29 22:15:22 2015with 64-bit io functions Copyright (c) 1994 2015 Bernard van Duijnen All rights reserved. Strictly Oracle Internal Use Only DUL: Warning: Recreating file "dul.log"Reading SCANNEDLOBPAGE.dat 1204 entries loaded and sorted 1204 entriesReading SEG.dat 0 entries loadedReading EXT.dat 44 entries loaded and sorted 44 entriesReading COMPATSEG.dat 0 entries loaded DUL: Warning: Wrong DBA 0X00440004 (file=1, block=262148) (Ignored)DUL: Error: While processing file# 30 block# 1DUL: Warning: Found mismatch while checking file E:\TEMP\shebao\30.dbfDUL: Warning: DUL osd_parameter or control.dul configuration errorDUL: Warning: Given file number(30) in control file does not match file# in dba(1)DUL: Warning: Wrong DBA 0X00440004 (file=1, block=262148) (Ignored)DUL: Error: While processing file# 30 block# 1DUL>
通過bbed和dul證明檔案頭大量損壞,而且尚未有任何該檔案的物理備份,因此恢複起來難道較大。
分析Oracle Database Recovery Check Result
通過對Oracle資料庫異常恢複檢查指令碼(Oracle Database Recovery Check)的分析結果,我們意外的發現,人品不錯,發現異常的檔案建立時間為2015-09-26 19:39:33,進一步和客戶溝通,這個檔案儲存體為圖片,少量丟失可以允許,優先恢複業務
有了這個結論,那處理起來就easy了,直接offline異常檔案,然後分析丟失的表
從而確定時lob字典的少量extent資料分配到了file 30上
為了避免查詢對應lob之時出現錯誤,通過update 對應lob為空白規避該問題
create table corrupt_lobs (corrupt_rowid rowid,table_name varchar2(100)); declare n number; begin for cursor_lob in (select rowid r, xff_lob from xff.t_xifenfei) loop begin n:=dbms_lob.instr(cursor_lob.xff_lob,hextoraw('889911')); exception when others then insert into corrupt_lobs values (cursor_lob.r,'xff.t_xifenfei'); commit; end; end loop; end; / update xff.t_xifenfei set xff_lob = empty_blob() where rowid in (select corrupted_rowid from corrupt_lobs);
本次恢複是由於運氣好,遇到異常檔案剛好是最近加入,而且都是圖片,客戶允許少量丟失,如果是不允許丟失的資料檔案,可能需要通過找曆史的該檔案的備份(Oracle 12C的第一次異常恢複—檔案頭壞塊),在某些情況下,如果也沒有此類備份,只能通過bbed重構block 1(如果有其他異常塊一次處理,如果太多無法處理,最少也需要重構block 1),然後嘗試open資料庫或者使用dul之類工具處理(因為檔案頭損壞,工具可能不能識別檔案無法恢複)