1104File Space Bitmap Block損壞能修復嗎

lfree發表於2016-11-04

[20161104]File Space Bitmap Block損壞能修復嗎?.txt

-- 連結http://www.itpub.net/thread-2071023-1-1.html提到File Space Bitmap Block損壞,問能修復嗎?

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

CREATE TABLESPACE SUGAR DATAFILE
  '/mnt/ramdisk/book/sugar01.dbf' SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

create table t1 tablespace sugar as select rownum id ,lpad('A',32,'A') name from dual connect by level<=1e5;
--建立大小5M的表。

create table t2 tablespace sugar as select rownum id ,lpad('B',32,'B') name from dual connect by level<=2e5;
create table t3 tablespace sugar as select rownum id ,lpad('C',32,'C') name from dual connect by level<=2e5;
alter system checkpoint;

2.假設File Space Bitmap Block損壞了。
--全部選擇F看看。

SYS@book> execute dbms_space_admin.tablespace_dump_bitmaps('SUGAR');
PL/SQL procedure successfully completed.

*** 2016-11-04 16:23:39.634
*** SESSION ID:(24.507) 2016-11-04 16:23:39.634
*** CLIENT ID:() 2016-11-04 16:23:39.634
*** SERVICE NAME:(SYS$USERS) 2016-11-04 16:23:39.634
*** MODULE NAME:(sqlplus@gxqyydg4 (TNS V1-V3)) 2016-11-04 16:23:39.634
*** ACTION NAME:() 2016-11-04 16:23:39.634

Header Control:
RelFno: 6, Unit: 8, Size: 5120, Flag: 9
AutoExtend: YES, Increment: 2048, MaxSize: 4194302
Initial Area: 126, Tail: 5119, First: 400, Free: 224
Deallocation scn: 925704.0
Header Opcode:
Save: No Pending Op
File Space Bitmap Block:
BitMap Control:
RelFno: 6, BeginBlock: 128, Flag: 0, First: 400, Free: 63088
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFF FFFFFFFFFFFFFFFF FFFF000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000

-- 16*6+4=100
-- 1bit 表示 64K。 F(0x1111) 表示4 bits.
-- 100*4*64*1024/8192=3200塊 ,3200*8192/1024/1024=25, 點陣圖資訊對的。

--假設現在壞了,我全部修改為F是否可行呢?

--檔案大小40M,40*1024*1024/8192=5120塊。40*1024*1024/64/1024=640bit,640/4=160個F。

3.我直接使用bvi修改檔案看看:

SYS@book> alter tablespace sugar offline ;
Tablespace altered.

--安全期間,做一個備份:
$ cp /mnt/ramdisk/book/sugar01.dbf /u01/backup/sugar01.dbf_0161104

--正常資料檔案第1塊OS。第2塊是檔案頭,第3塊開始-128塊是點陣圖區。

--我檔案很小,估計在1塊裡面:
--8192*3=24576

$ bvi -b 24576 -s 8192 /mnt/ramdisk/book/sugar01.dbf

--前面已經100個F,我僅僅加入60個。

--修改如下:
00006000  1E A2 00 00 03 00 80 01 64 F8 26 00 00 00 01 04 22 B1 00 00 06 00 00 00 80 00 00 00 00 00 00 00 ........d.&....."...............
00006020  90 01 00 00 70 F6 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF ....p...........................
00006040  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................................
00006060  FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................................
00006080  FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000060A0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000060C0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
000060E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00006100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00006120  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00006140  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00006160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
"

BBED> set dba 6,3
        DBA             0x01800003 (25165827 6,3)

BBED> map
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 3                                     Dba:0x01800003
------------------------------------------------------------
BBED-00400: invalid blocktype (30)

BBED> sum
Check value for File 6, Block 3:
current = 0xb122, required = 0x4edd

BBED> sum apply
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Check value for File 6, Block 3:
current = 0x4edd, required = 0x4edd

BBED> verify
DBVERIFY - Verification starting
FILE = /mnt/ramdisk/book/sugar01.dbf
BLOCK = 3


DBVERIFY - Verification complete
Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
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
Message 531 not found;  product=RDBMS; facility=BBED

$ dbv file=sugar01.dbf
DBVERIFY: Release 11.2.0.4.0 - Production on Fri Nov 4 16:42:32 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
DBVERIFY - Verification starting : FILE = /mnt/ramdisk/book/sugar01.dbf
Page 3 failed with check code 18018
DBVERIFY - Verification complete
Total Pages Examined         : 5120
Total Pages Processed (Data) : 2974
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 201
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 1945
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 2553960 (0.2553960)


SYS@book> alter tablespace sugar  online;
Tablespace altered.

SYS@book> alter tablespace sugar  read only;
Tablespace altered.

SYS@book> select count(*) from scott.t1;
  COUNT(*)
----------
    100000

SYS@book> select count(*) from scott.t2;
  COUNT(*)
----------
    200000

SYS@book> select count(*) from scott.t3;
  COUNT(*)
----------
    200000

--OK!問題在與如何構造這個資訊塊。

4.其他測試:
SYS@book> execute dbms_space_admin.tablespace_dump_bitmaps('SUGAR');
BEGIN dbms_space_admin.tablespace_dump_bitmaps('SUGAR'); END;

*
ERROR at line 1:
ORA-03219: Tablespace 'SUGAR' is dictionary-managed, offline or temporary
ORA-06512: at "SYS.DBMS_SPACE_ADMIN", line 322
ORA-06512: at line 1

--在只讀情況執行報錯。

SYS@book> alter tablespace sugar  read write;
Tablespace altered.

SYS@book> execute dbms_space_admin.tablespace_dump_bitmaps('SUGAR');
PL/SQL procedure successfully completed.

SYS@book> alter system dump datafile 6 block 3 ;
System altered.

SYS@book> alter tablespace sugar  read only;
Tablespace altered.

BBED> set dba 6,3
        DBA             0x01800003 (25165827 6,3)

BBED> dump /v count 8192
File: /mnt/ramdisk/book/sugar01.dbf (6)
Block: 3                                 Offsets:    0 to  255                            Dba:0x01800003
-----------------------------------------------------------------------------------------------------------
1ea20000 03008001 64f82600 00000104 dd4e0000 06000000 80000000 00000000 l ........d.&......N..............
90010000 70f60000 00000000 00000000 00000000 00000000 ffffffff ffffffff l ....p...........................
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff l ................................
ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff l ................................
ffffffff ffffffff 00000000 00000000 00000000 00000000 00000000 00000000 l ................................
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 l ................................
....
00000000 00000000 00000000 00000000 00000000 00000000 00000000 011e64f8 l ..............................d.
<32 bytes per line>

--問題在與前面部分如何構造。

5.在建立一個相同大小的表空間看看。

CREATE TABLESPACE TEA DATAFILE
  '/mnt/ramdisk/book/tea01.dbf' SIZE 40M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

BBED> set dba 7,3
        DBA             0x01c00003 (29360131 7,3)

BBED> dump /v count 8192
File: /mnt/ramdisk/book/tea01.dbf (7)
Block: 3                                 Offsets:    0 to 8191                            Dba:0x01c00003
-----------------------------------------------------------------------------------------------------------
1ea20000 0300c001 18fd2600 00000104 7c410000 07000000 80000000 00000000 l ..........&.....|A..............
00000000 00f80000 00000000 00000000 00000000 00000000 00000000 00000000 l ................................
...
00000000 00000000 00000000 00000000 00000000 00000000 00000000 011e18fd l ................................
<32 bytes per line>

--順便取一個資料塊分析對照:
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        0x018000e6
   ub4 bas_kcbh                             @8        0x0026f7c5
   ub2 wrp_kcbh                             @12       0x0000
   ub1 seq_kcbh                             @14       0x02
   ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)
   ub2 chkval_kcbh                          @16       0x1c51
   ub2 spare3_kcbh                          @18       0x0000
------

--做一個不完全分析:
1ea20000 相同。
0300c001 這個dba地址。

BBED> set dba 6,3
        DBA             0x01800003 (25165827 6,3)

BBED> set dba 7,3
        DBA             0x01c00003 (29360131 7,3)

18fd2600 scn號,低位元組18fd與tail對應一樣。

-- 7c41是檢查和。
BBED> set dba 7,3
        DBA             0x01c00003 (29360131 7,3)
BBED> sum
Check value for File 7, Block 3:
current = 0x417c, required = 0x417c

07000000 ==> 我看了其他檔案這個視乎是檔案號,亂猜。

--後面我不敢猜測了。
--主要是 90010000 70f60000 , 我猜測不出來。

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

相關文章