[20161111File Space Bitmap Block修復機制

lfree發表於2016-11-11

[20161111]File Space Bitmap Block修復機制.txt

--前幾天在測試File Space Bitmap Block時執行了,execute dbms_space_admin.TABLESPACE_REBUILD_BITMAPS('SUGAR')
--這樣點陣圖區全部設定為1,顯示都是F。它的修復機制不是非常清楚,今天做一些深入的探究。

--繼續重複昨天的測試。

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.轉儲點陣圖區資訊:

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

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
0000000000000000 0000000000000000 0000000000000000 0000000000000000
0000000000000000 0000000000000000 0000000000000000 0000000000000000

$ bvi -b 24576 -s 8192 /mnt/ramdisk/book/sugar01.dbf
00006000  1E A2 00 00 03 00 80 01 25 DC 5F 00 00 00 01 04 5B B1 00 00 06 00 00 00 80 00 00 00 00 00 00 00 ........%._.....[...............
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 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00006080  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 ................................
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 ................................

-- 偏移 60 後僅僅 10個 FF。

--關閉資料庫重新啟動,並且dba 6,3 全部FF變為00.注意其他不動,注意要重新計算檢查和。

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

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

--啟動資料庫。
SYS@book> @ &r/bh 6 3
no rows selected

--可以發現現在該資料塊沒有在資料快取中。

3.分析執行過程:

SYS@book> @ &r/spid

       SID    SERIAL# SPID       PID  P_SERIAL# C50
---------- ---------- ------ ------- ---------- --------------------------------------------------
       232          7 5574        21          4 alter system kill session '232,7' immediate;


--開啟另外終端執行:
$ strace -f -p 5574 -o /tmp/map.txt

--切換回去:
SYS@book> execute dbms_space_admin.TABLESPACE_REBUILD_BITMAPS('SUGAR');
PL/SQL procedure successfully completed.

$ bvi -b 24576 -s 8192 /mnt/ramdisk/book/sugar01.dbf
00006000  1E A2 00 00 03 00 80 01 B7 D6 5F 00 00 00 02 04 44 41 00 00 06 00 00 00 80 00 00 00 00 00 00 00 .........._.....DA..............
00006020  00 F8 00 00 00 00 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 ................................
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 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................................
000060A0  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 ................................
000060C0  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 ................................
000060E0  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 ................................
00006100  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 ................................
00006120  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 ................................
00006140  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 ................................
00006160  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 ................................
00006180  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 ................................
000061A0  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 ................................
000061C0  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 ................................
000061E0  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 ................................
00006200  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 ................................
00006220  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 ................................
00006240  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 ................................
00006260  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 ................................
00006280  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 ................................
000062A0  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 ................................
000062C0  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 ................................
000062E0  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 ................................

--你可以發現資料檔案的點陣圖區塊裡面全是F。表示已經使用,而實際上你檢查對應的記憶體塊:

SYS@book> @ &r/bh 6 3
HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               OBJECT_NAME
---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- --------------------
0000000084B84748          6          3         12 bitmap index block free                0          0          0          0          0          0 00000000756A8000
0000000084B84748          6          3         12 bitmap index block xcur                1          0          0          0          0          0 00000000756AA000

--STATE=xcur BA=00000000756AA000
--你可以發現FF從32+24=56 開始,56 = 0x38

SYS@book> oradebug setmypid
Statement processed.

SYS@book> oradebug peek 0x00000000756AA000 16
[0756AA000, 0756AA010) = 0000A21E 01800003 005FDC25 00010000

--00006000  1E A2 00 00 03 00 80 01 B7 D6 5F 00 00 00 02 04 44 41 00 00 06 00 00 00 80 00 00 00 00 00 00 00 .........._.....DA..............
                        ~~~~~~~~~~~
--大小頭對調可以發現的dba地址一致。

SYS@book> oradebug peek 0x00000000756AA038 16
[0756AA038, 0756AA048) = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
--全是FF

SYS@book> oradebug peek 0x00000000756AA060 16
[0756AA060, 0756AA070) = FFFFFFFF FFFFFFFF 0000FFFF 00000000

SYS@book> oradebug peek 0x00000000756AA100 16
[0756AA100, 0756AA110) = 00000000 00000000 00000000 00000000

--而偏移量0x100= 256,全都是00.也就是記憶體中的資料塊是正確,由此可以推出他的恢復機制,先修改資料塊設定FF,讀取到快取中然
--後掃描分析資料塊,在記憶體資料塊中標識那些塊使用了。

--如果你發出alter system checkpoint,這樣記憶體的資訊寫到資料檔案中,結果就是正確的。

SYS@book> alter system checkpoint;
System altered.

SYS@book> @ &r/bh 6 3
old  23:   dbarfil = &1 and
new  23:   dbarfil = 6 and
old  24:   dbablk = &2
new  24:   dbablk = 3
HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               OBJECT_NAME
---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- --------------------
0000000084B84748          6          3         12 bitmap index block free                0          0          0          0          0          0 00000000756A8000
0000000084B84748          6          3         12 bitmap index block xcur                1          0          0          0          0          0 00000000756AA000

$ bvi -b 24576 -s 8192 /mnt/ramdisk/book/sugar01.dbf
00006000  1E A2 00 00 03 00 80 01 25 DC 5F 00 00 00 01 04 5B B1 00 00 06 00 00 00 80 00 00 00 00 00 00 00 ........%._.....[...............
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 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00006080  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 ................................
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 ................................

--可以發現已經修復了。根本不需要擔心開始全部寫入FF,標識全部使用,實際上記憶體對應的資料塊是正確的。

4.深入分析:

--檢查跟蹤檔案
# ls -l /proc/5574/fd
total 0
lr-x------ 1 oracle oinstall 64 2016-11-11 10:52:23 0 -> /dev/null
l-wx------ 1 oracle oinstall 64 2016-11-11 10:52:23 1 -> /dev/null
l-wx------ 1 oracle oinstall 64 2016-11-11 10:52:23 12 -> pipe:[19152388]
l-wx------ 1 oracle oinstall 64 2016-11-11 10:52:23 2 -> /dev/null
lrwx------ 1 oracle oinstall 64 2016-11-11 10:54:01 256 -> /mnt/ramdisk/book/sugar01.dbf
lrwx------ 1 oracle oinstall 64 2016-11-11 10:54:01 258 -> /mnt/ramdisk/book/system01.dbf
lr-x------ 1 oracle oinstall 64 2016-11-11 10:52:23 3 -> /dev/null
lr-x------ 1 oracle oinstall 64 2016-11-11 10:52:23 4 -> /u01/app/oracle/product/11.2.0.4/dbhome_1/rdbms/mesg/oraus.msb
lr-x------ 1 oracle oinstall 64 2016-11-11 10:52:23 5 -> /proc/5574/fd
lr-x------ 1 oracle oinstall 64 2016-11-11 10:52:23 6 -> /dev/zero
lrwx------ 1 oracle oinstall 64 2016-11-11 10:52:23 7 -> /u01/app/oracle/admin/book/adump/book_ora_5574_20161111105146035812143795.aud
lr-x------ 1 oracle oinstall 64 2016-11-11 10:52:23 9 -> pipe:[19152387]

$ grep write /tmp/map.txt
5197  write(12, "\0\265\0\0\6\0\0\0\0\0\10\6\0\274\333_\0\0\0\0\0\10\0\0\0\0\0\0\0\0\0\0"..., 181) = 181
5197  write(12, "\0\21\0\0\6\0\0\0\0\0\t\1\0\0\0\0\0", 17) = 17
--寫很少,不知道什麼回事。

$ grep pread /tmp/map.txt
5197  pread(258, "\6\242\0\0008\17@\0\271v\16\0\0\0\1\6v\225\0\0\1\0\0\0\10\0\0\0\270v\16\0"..., 32768, 31916032) = 32768
5197  pread(258, "\6\242\0\0\363\26@\0\2544\0\0\0\0\2\4\36\202\0\0\1\0\0\0\10\0\0\0\2544\0\0"..., 24576, 48128000) = 24576
5197  pread(258, "\6\242\0\0\361\35@\0\353@\0\0\0\0\2\4\r\301\0\0\1\0\0\0\10\0\0\0\353@\0\0"..., 8192, 62791680) = 8192
5197  pread(258, "\6\242\0\0s5@\0\231@\3\0\0\0\3\4\211\305\0\0\1\0\6\0\10\0\0\0\231@\3\0"..., 8192, 112091136) = 8192
5197  pread(258, "\6\242\0\0u5@\0\255\266\1\0\0\0\1\6\215\221\0\0\1\0\0\0\10\0\0\0\237\266\1\0"..., 16384, 112107520) = 16384
5197  pread(258, "\6\242\0\0pm@\0\313\327\2\0\0\0\1\6\205_\0\0\1\0 \0\10\0\0\0x\327\2\0"..., 8192, 229507072) = 8192
5197  pread(258, "\6\242\0\0rm@\0\261\341\2\0\0\0\1\6\317}\0\0\1\0\24\0\10\0\0\0006\341\2\0"..., 8192, 229523456) = 8192
5197  pread(258, "\6\242\0\0\246!A\0r+\16\0\0\0\1\6F\323\0\0\1\0\33\0\10\0\0\0\274*\16\0"..., 8192, 607436800) = 8192
5197  pread(258, "\6\242\0\0\252!A\0\223\26\17\0\0\0\1\6s\322\0\0\1\0@\0\10\0\0\0\222\26\17\0"..., 8192, 607469568) = 8192
5197  pread(258, "\6\242\0\0\254!A\0\264m\16\0\0\0\2\4k\6\0\0\1\0@\0\10\0\0\0\264m\16\0"..., 40960, 607485952) = 40960
5197  pread(263, "#\242\0\0\202\0\200\1-\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 1064960) = 8192
5197  pread(263, "#\242\0\0\2\3\200\1v\320_\0\0\0\1\4\322\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 6307840) = 8192
5197  pread(263, "#\242\0\0\2\10\200\1\270\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 16793600) = 8192
5197  pread(258, "\6\242\0\0\265!A\0l\224\16\0\0\0\3\0040\324\0\0\1\0\0\0\10\0\0\0l\224\16\0"..., 16384, 607559680) = 16384
5197  pread(263, "#\242\0\0\202\0\200\1-\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 1064960) = 8192
5197  pread(258, "\6\242\0\0\36\v@\0\244\"\3\0\0\0\1\6\322\333\0\0\1\0\0\0\274\1\0\0\241\"\3\0"..., 8192, 23314432) = 8192
5197  pread(258, "\6\242\0\0\37\v@\0\244\"\3\0\0\0\1\6A\301\0\0\1\0\0\0\274\1\0\0\242\"\3\0"..., 8192, 23322624) = 8192
5197  pread(258, "\6\242\0\0\305\3@\0\2228\17\0\0\0\1\6\211+\0\0\2\0\0\0y\0\0\0\2168\17\0"..., 8192, 7905280) = 8192
5197  pread(258, "\6\242\0\0\253\3@\0\2228\17\0\0\0\1\6\375\316\0\0\1\0\36\0v\0\0\0\2168\17\0"..., 8192, 7692288) = 8192
5197  pread(263, "#\242\0\0\2\3\200\1v\320_\0\0\0\1\4\322\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 6307840) = 8192
5197  pread(263, "#\242\0\0\2\10\200\1\270\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 16793600) = 8192

--先分析263控制程式碼的情況:
$ grep pread /tmp/map.txt | grep '263,'
5197  pread(263, "#\242\0\0\202\0\200\1-\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 1064960) = 8192
5197  pread(263, "#\242\0\0\2\3\200\1v\320_\0\0\0\1\4\322\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 6307840) = 8192
5197  pread(263, "#\242\0\0\2\10\200\1\270\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 16793600) = 8192
5197  pread(263, "#\242\0\0\202\0\200\1-\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 1064960) = 8192
5197  pread(263, "#\242\0\0\2\3\200\1v\320_\0\0\0\1\4\322\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 6307840) = 8192
5197  pread(263, "#\242\0\0\2\10\200\1\270\320_\0\0\0\1\4\321\361\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 8192, 16793600) = 8192

--1064960/8192=130
--6307840/8192=770
--16793600/8192=2050

SYS@book> select segment_name,header_file,header_block from dba_segments where owner='SCOTT' and header_file=6;
SEGMENT_NAME         HEADER_FILE HEADER_BLOCK
-------------------- ----------- ------------
T3                             6         2050
T2                             6          770
T1                             6          130

--正好是表T1,T2,T3的塊頭。也就是透過掃描表頭,確定那些段使用了,回填點陣圖區的資訊。

5.做一個極端測試:

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

SYS@book> shutdown abort
ORACLE instance shut down.

$ bvi -b 24576 -s 8192 /mnt/ramdisk/book/sugar01.dbf
00006000  1E A2 00 00 03 00 80 01 32 F5 5F 00 00 00 02 04 44 41 00 00 06 00 00 00 80 00 00 00 00 00 00 00 ........2._.....DA..............
00006020  00 F8 00 00 00 00 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 ................................
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 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................................
000060A0  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 ................................
000060C0  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 ................................
000060E0  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 ................................

--可以發現是FF。然後重新啟動資料庫到mount狀態。

SYS@book> startup mount
ORACLE instance started.

Total System Global Area  634732544 bytes
Fixed Size                  2255792 bytes
Variable Size             197133392 bytes
Database Buffers          427819008 bytes
Redo Buffers                7524352 bytes
Database mounted.

RMAN> backup datafile 6 format '/u01/backup/d6_1.bak' ;
Starting backup at 2016-11-11 11:11:08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/mnt/ramdisk/book/sugar01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-11-11 11:11:09
channel ORA_DISK_1: finished piece 1 at 2016-11-11 11:11:10
piece handle=/u01/backup/d6_1.bak tag=TAG20161111T111109 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-11-11 11:11:10

$ ls -l /u01/backup/d6_1.bak
-rw-r----- 1 oracle oinstall 26066944 2016-11-11 11:11:09 /u01/backup/d6_1.bak

$ ls -lh /u01/backup/d6_1.bak
-rw-r----- 1 oracle oinstall 25M 2016-11-11 11:11:09 /u01/backup/d6_1.bak

--大小26066944/1024/1024=24.859375M,可以發現備份並不依賴這個點陣圖區掃描。

SYS@book> alter database open ;
Database altered.

SYS@book> @ &r/bh 6 3
HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               OBJECT_NAME
---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- --------------------
0000000084B84748          6          3         12 bitmap index block xcur                0          0          0          0          0          0 000000007A3C4000

SYS@book> alter system checkpoint;
System altered.

00006000  1E A2 00 00 03 00 80 01 32 F5 5F 00 00 00 02 04 44 41 00 00 06 00 00 00 80 00 00 00 00 00 00 00 ........2._.....DA..............
00006020  00 F8 00 00 00 00 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 ................................
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 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................................
000060A0  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 ................................
000060C0  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 ................................
000060E0  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 ................................
--可以發現並沒有修復點陣圖區。

SYS@book> alter system checkpoint;
System altered.

SYS@book> oradebug setmypid
Statement processed.

SYS@book> oradebug peek 0x000000007A3C4100 16
[07A3C4100, 07A3C4110) = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF

--從這裡看也可以證明沒有修復。

SCOTT@book> create table t4 tablespace sugar as select rownum id ,lpad('D',32,'D') name from dual connect by level<=1e5;
create table t4 tablespace sugar as select rownum id ,lpad('D',32,'D') name from dual connect by level<=1e5
                                                                                 *
ERROR at line 1:
ORA-00600: internal error code, arguments: [ktfbbssearch-9], [0], [624], [63488], [], [], [], [], [], [], [], []

--建表發現錯誤。

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

SCOTT@book> create table t4 tablespace sugar as select rownum id ,lpad('D',32,'D') name from dual connect by level<=1e5;
Table created.

--OK,現在建表成功。

SCOTT@book> column PARTITION_NAME noprint
SCOTT@book> select * from dba_extents where owner=user and segment_name in ('T3','T4');
OWNER  SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME  EXTENT_ID    FILE_ID   BLOCK_ID      BYTES     BLOCKS RELATIVE_FNO
------ ------------ ------------ --------------- ---------- ---------- ---------- ---------- ---------- ------------
SCOTT  T3           TABLE        SUGAR                    0          6       2048      65536          8            6
SCOTT  T3           TABLE        SUGAR                    1          6       2056      65536          8            6
....
SCOTT  T3           TABLE        SUGAR                   21          6       2816    1048576        128            6
SCOTT  T3           TABLE        SUGAR                   22          6       2944    1048576        128            6
SCOTT  T3           TABLE        SUGAR                   23          6       3072    1048576        128            6
SCOTT  T3           TABLE        SUGAR                   24          6       3200    1048576        128            6
SCOTT  T4           TABLE        SUGAR                    0          6       3328      65536          8            6
...
SCOTT  T4           TABLE        SUGAR                   17          6       3584    1048576        128            6
SCOTT  T4           TABLE        SUGAR                   18          6       3712    1048576        128            6
SCOTT  T4           TABLE        SUGAR                   19          6       3840    1048576        128            6
45 rows selected.

--t3,T4的空間是連續的。

--看來做後臺資料維護最大的敵人是當機或者掉電。

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

相關文章