[20150527]bbed解決資料檔案大小問題.txt

lfree發表於2015-05-27

[20150527]bbed解決資料檔案大小問題.txt

--模擬一個資料檔案大小不一致的問題.

1.建立測試環境:

SCOTT@test> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx            10.2.0.4.0     Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

SCOTT@test> select file#,name,bytes from v$datafile ;
FILE# NAME                                     BYTES
----- --------------------------------- ------------
    1 /mnt/ramdisk/test/system01.dbf       534773760
    2 /mnt/ramdisk/test/undotbs01.dbf      367001600
    3 /mnt/ramdisk/test/sysaux01.dbf       387973120
    4 /mnt/ramdisk/test/users01.dbf        104857600
    5 /mnt/ramdisk/test/example01.dbf      104857600
    6 /mnt/ramdisk/test/mssm01.dbf          16777216
6 rows selected.

$  ls -l /mnt/ramdisk/test/mssm01.dbf
-rw-r----- 1 oracle oinstall 16785408 2015-05-27 10:52:05 /mnt/ramdisk/test/mssm01.dbf

16785408-16777216=8192
--可以發現檢視v$datafile顯示的與os看的有8192位元組差距,實際上前面1塊OS塊,記錄一個OS資訊.

--16777216=16M,不好觀察資料檔案的大小的定義在什麼位置.
SCOTT@test> select (16777216-2*64*1024)/1024 from dual ;
(16777216-2*64*1024)/1024
-------------------------
                    16256

SCOTT@test> ALTER DATABASE DATAFILE '/mnt/ramdisk/test/mssm01.dbf' RESIZE 16256K;
Database altered.

16256/8=2032
2032 = 0x7f0

--透過bbed觀察:
BBED> set dba 6,1
        DBA             0x01800001 (25165825 6,1)

BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes                   @20
   ub4 kccfhswv                             @20       0x00000000
   ub4 kccfhcvn                             @24       0x0a200300
   ub4 kccfhdbi                             @28       0x80f1c038
   text kccfhdbn[0]                         @32      T
   text kccfhdbn[1]                         @33      E
   text kccfhdbn[2]                         @34      S
   text kccfhdbn[3]                         @35      T
   text kccfhdbn[4]                         @36
   text kccfhdbn[5]                         @37
   text kccfhdbn[6]                         @38
   text kccfhdbn[7]                         @39
   ub4 kccfhcsq                             @40       0x33c3d8a7
   ub4 kccfhfsz                             @44       0x000007f0

--應該是kcvfhhdr.kccfhfsz欄位.

2.安全第1,關閉資料庫,做一個冷備份:
--步驟忽略.

3.修改偏移量44,45:
--FF,7F ,注意要反過來. 相當於修改為07FF=2047.

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

4.啟動資料庫觀察:
SYS@test> startup
ORACLE instance started.
Total System Global Area    473956352 bytes
Fixed Size                    2084776 bytes
Variable Size               260046936 bytes
Database Buffers            201326592 bytes
Redo Buffers                 10498048 bytes
Database mounted.
ORA-01122: database file 6 failed verification check
ORA-01110: data file 6: '/mnt/ramdisk/test/mssm01.dbf'
ORA-01200: actual file size of 2032 is smaller than correct size of 2047 blocks

5.修改很簡單,修改原來的44,45位元組為正確的 2032 = 0x7f0.

BBED> set dba 6,1
        DBA             0x01800001 (25165825 6,1)

BBED> p kcvfhhdr.kccfhfsz
ub4 kccfhfsz                                @44       0x000007ff

BBED> modify /x f007

BBED> p kcvfhhdr.kccfhfsz
ub4 kccfhfsz                                @44       0x000007f0


BBED> sum apply
Check value for File 6, Block 1:
current = 0x963d, required = 0x963d

SYS@test> startup
ORACLE instance started.
Total System Global Area    473956352 bytes
Fixed Size                    2084776 bytes
Variable Size               260046936 bytes
Database Buffers            201326592 bytes
Redo Buffers                 10498048 bytes
Database mounted.
Database opened.

--OK現在正常了,這種錯誤可能出現磁碟滿了,而空間增加的情況,不過真實的模擬存在一些難度,至少我沒有模擬出來.修改方法應該就像上面的介紹.

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

相關文章