[20150527]bbed解决数据文件大小问题.txt

[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现在正常了,这种错误可能出现磁盘满了,而空间增加的情况,不过真实的模拟存在一些难度,至少我没有模拟出来.修改方法应该就像上面的介绍.

上一篇:Android免费集成推送功能(MobPush)


下一篇:unix domain socket进程凭据