笔记本上安装的 oracle 9208数据库在演示RMAN备份时发现system01.dbf有一坏块,用dbv检查如下:
C:\Documents and Settings\bwen>dbv file=D:\ oracle \oradata\bright\system01.dbf blocksize=8192
DBVERIFY: Release 9.2.0.8.0 - Production on 星期二 11月 17 15:15:25 2009
Copyright (c) 1982, 2002, oracle Corporation. All rights reserved
DBVERIFY - 验证正在开始 : FILE = D:\ oracle \oradata\bright\system01.dbf
汇入的页23523 - 可能是介质损坏
***
Corrupt block relative dba: 0×00405be3 (file 1, block 23523)
Fractured block found during dbv:
Data in bad block -
type: 6 format: 2 rdba: 0×00405be3
last change scn: 0×0000.0000ce66 seq: 0×1 flg: 0×04
consistency value in tail: 0×00000000
check value in block header: 0×3013, computed block checksum: 0×62e
spare1: 0×0, spare2: 0×0, spare3: 0×0
***DBVERIFY - 验证完成
检查的页总数 :51200
处理的页总数(数据):36265
失败的页总数(数据):0
处理的页总数(索引):4227
失败的页总数(索引):0
处理的页总数(其它):1747
处理的总页数 (段) : 0
失败的总页数 (段) : 0
空的页总数 :8960
标记为损坏的总页数:1
汇入的页总数 :1
Highest block SCN : 2034199 (0.2034199)
从红色部分我们可以看出几个问题:
1.tail check的值跟scn base,scn seq,block type三者的值不匹配。
正常情况下tail check=scn base+block type+scn seq
2.block header的checksum的值跟计算出来的checksum值不一致
3.一般来说如果是坏块, oracle 会把scn seq设置成0xff,但这边的值是0×1
通过检查发现坏块对应的对象为idl_ub1$,该系统表的作用可参看eygle的文章。尝试查询报如下错误:
SQL> select count(*) from idl_ub1$;
select count(*) from idl_ub1$
*
ERROR 位于第 1 行:
ORA-01578: oracle 数据块损坏(文件号1,块号23523)
ORA-01110: 数据文件 1: ‘D:\ oracle \ORADATA\BRIGHT\SYSTEM01.DBF’
对于该坏块的修复,正常的方法参考:http://www.dbifan.com/200609/oracle-bad-block.html
前两天刚好看到ningoo用bbed处理了一个问题,于是也尝试一下用bbed来修复该坏块。
C:\Documents and Settings\bwen>bbed parfile=d:\ oracle \ora92\bin\bbed.par
口令:
BBED: Release 2.0.0.0.0 - Limited Production on 星期三 11月 18 11:05:05 2009
Copyright (c) 1982, 2002, oracle Corporation. All rights reserved.
************* !!! For oracle Internal Use only !!! ***************
BBED> show
FILE# 1
BLOCK# 1
OFFSET 0
DBA 0×00400001 (4194305 1,1)
FILENAME D:\ oracle \oradata\bright\SYSTEM01.DBF
BIFILE bifile.bbd
LISTFILE D:\ oracle \ora92\bin\filelist.log
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
BBED> set block 23523
BLOCK# 23523
BBED> map /v
File: D:\ oracle \oradata\bright\SYSTEM01.DBF (1)
Block: 23523 Dba:0×00405be3
————————————————————
KTB Data Block (Table/Cluster)
struct kcbh, 20 bytes @0
ub1 type_kcbh @0
ub1 frmt_kcbh @1
ub1 spare1_kcbh @2
ub1 spare2_kcbh @3
ub4 rdba_kcbh @4
ub4 bas_kcbh @8
ub2 wrp_kcbh @12
ub1 seq_kcbh @14
ub1 flg_kcbh @15
ub2 chkval_kcbh @16
ub2 spare3_kcbh @18
struct ktbbh, 96 bytes @20
ub1 ktbbhtyp @20
union ktbbhsid, 4 bytes @24
struct ktbbhcsc, 8 bytes @28
b2 ktbbhict @36
ub1 ktbbhflg @38
ub1 ktbbhfsl @39
ub4 ktbbhfnx @40
struct ktbbhitl[3], 72 bytes @44
struct kdbh, 14 bytes @116
ub1 kdbhflag @116
b1 kdbhntab @117
b2 kdbhnrow @118
sb2 kdbhfrre @120
sb2 kdbhfsbo @122
sb2 kdbhfseo @124
b2 kdbhavsp @126
b2 kdbhtosp @128
struct kdbt[1], 4 bytes @130
b2 kdbtoffs @130
b2 kdbtnrow @132
sb2 kdbr[1] @134
ub1 freespace[53] @136
ub1 rowdata[7999] @189
ub4 tailchk @8188BBED> p offset 14
kcbh.seq_kcbh
————-
ub1 seq_kcbh @14 0×01BBED> p offset 8
kcbh.bas_kcbh
————-
ub4 bas_kcbh @8 0×0000ce66BBED> p kcbh
struct kcbh, 20 bytes @0
ub1 type_kcbh @0 0×06
ub1 frmt_kcbh @1 0×02
ub1 spare1_kcbh @2 0×00
ub1 spare2_kcbh @3 0×00
ub4 rdba_kcbh @4 0×00405be3
ub4 bas_kcbh @8 0×0000ce66
ub2 wrp_kcbh @12 0×0000
ub1 seq_kcbh @14 0×01
ub1 flg_kcbh @15 0×04 (KCBHFCKV)
ub2 chkval_kcbh @16 0×3013
ub2 spare3_kcbh @18 0×0000BBED> p tailchk
ub4 tailchk @8188 0×00000000BBED> m /x 010666ce offset 8188 –根据little-endian的规则,0xce660601写成:01 06 66 ce
File: D:\ oracle \oradata\bright\SYSTEM01.DBF (1)
Block: 23523 Offsets: 8188 to 8191 Dba:0×00405be3
————————————————————————
010666ce
<32 bytes per line>BBED> p tailchk
ub4 tailchk @8188 0xce660601BBED> sum apply
Check value for File 1, Block 23523:
current = 0xf874, required = 0xf874BBED> verify
DBVERIFY - 验证正在启动
FILE =D:\ oracle \oradata\bright\SYSTEM01.DBF
BLOCK = 23523
DBVERIFY - 验证完成
检查的总块数:1
已处理的总块数(数据):1
无法处理的总块数(数据):0
已处理的总块数(索引):0
无法处理的总块数(索引):0
空的总块数:0
标记为损坏的总数块:0
汇入的块总数:0
如果此时数据库是open的,那么要restart,否则还会报错,因为此时该数据块可能已经被读进buffer了:
SQL> select count(*) from idl_ub1$;
select count(*) from idl_ub1$
*
ERROR 位于第 1 行:
ORA-01578: oracle 数据块损坏(文件号1,块号23523)
ORA-01110: 数据文件 1: ‘D:\ oracle \ORADATA\BRIGHT\SYSTEM01.DBF’
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
oracle 例程已经关闭。
SQL> startup
oracle 例程已经启动。
Total System Global Area 135339604 bytes
Fixed Size 454228 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
数据库装载完毕。
数据库已经打开。
SQL> select count(*) from idl_ub1$;
COUNT(*)
———-
32718
至此修复完成。
http://www.dbifan.com/200911/bbed-repair-bad-block.html