1.创建测试表 SQL> conn tes1t/test 1 Connected. SQL> create table testbbed as select * from dba_tables; Table created. SQL> col segment_name format a20; SQL> select segment_name,file_id,block_id from dba_extents where owner='TEST1' and segment_name='TESTBBED'; SEGMENT_NAME FILE_ID BLOCK_ID --------------------------------------------------------------------------------- ---------- ---------- TESTBBED 5 128 TESTBBED 5 136 TESTBBED 5 144 TESTBBED 5 152 TESTBBED 5 160 TESTBBED 5 168 TESTBBED 5 176 TESTBBED 5 184 TESTBBED 5 192 TESTBBED 5 200 TESTBBED 5 208 SEGMENT_NAME FILE_ID BLOCK_ID --------------------------------------------------------------------------------- ---------- ---------- TESTBBED 5 216 TESTBBED 5 224 TESTBBED 5 232 14 rows selected. 2.创建BBED参数文件 BBED无法对ASM操作 SQL> select file_id, file_name from dba_data_files; FILE_ID FILE_NAME ---------- -------------------------------------------------------------------------------------------------------------------------------------------------------------- 4 /u01/app/oracle/oradata/single2/users01.dbf 3 /u01/app/oracle/oradata/single2/undotbs01.dbf 2 /u01/app/oracle/oradata/single2/sysaux01.dbf 1 /u01/app/oracle/oradata/single2/system01.dbf 5 /u01/app/oracle/oradata/single2/test1.dbf [oracle@single2 ~]$ vi filelist.txt 5 /u01/app/oracle/oradata/single2/test1.dbf [oracle@single2 ~]$ vi bbed.par blocksize=8192 listfile=filelist.txt mode=edit 3.BBED基本操作 [oracle@single2 ~]$ bbed parfile=bbed.par Password: BBED: Release 2.0.0.0.0 - Limited Production on Wed Feb 17 03:46:16 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. ************* !!! For Oracle Internal Use only !!! *************** BBED> info all File# Name Size(blks) ----- ---- ---------- 5 /u01/app/oracle/oradata/single2/test1.dbf 0 BBED> set file 5 FILE# 5 BBED> show FILE# 5 BLOCK# 1 OFFSET 0 DBA 0x01400001 (20971521 5,1) FILENAME /u01/app/oracle/oradata/single2/test1.dbf BIFILE bifile.bbd LISTFILE filelist.txt BLOCKSIZE 8192 MODE Edit EDIT Unrecoverable IBASE Dec OBASE Dec WIDTH 80 COUNT 512 LOGFILE log.bbd SPOOL No 4.模拟坏块 BBED> modify 1000 file 5 block 136 --修改第二个segment File: /u01/app/oracle/oradata/single2/test1.dbf (5) Block: 136 Offsets: 0 to 511 Dba:0x01400088 ------------------------------------------------------------------------ 03e80000 88004001 b97a2f00 00000204 32c80000 01000000 895a0100 b27a2f00 00000000 03003201 80004001 ffff0000 00000000 00000000 00000000 00800000 b27a2f00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00011d00 ffff4c00 89033d03 3d030000 1d007b1e 791d731c 7b1b8c1a 9a19a718 b417c416 d115d814 e013ed12 fa110b11 1910260f 330e440d 4e0c530b 5c0a6c09 77088207 8a068d05 86048903 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <32 bytes per line> 如果修改错误,可以执行revert命令回滚 5.验证坏块 BBED> verify DBVERIFY - Verification starting FILE = /u01/app/oracle/oradata/single2/test1.dbf BLOCK = 136 Block 136 is corrupt ------------------------------------- Corrupt block relative dba: 0x01400088 (file 0, block 136) Bad header found during verification Data in bad block: type: 3 format: 0 rdba: 0x01400088 last change scn: 0x0000.002f7ab9 seq: 0x2 flg: 0x04 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x7ab90602 check value in block header: 0xc832 computed block checksum: 0x4a05 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 : 1 Total Blocks Influx : 0 Message 531 not found; product=RDBMS; facility=BBED 6.DBV验证 [oracle@single2 ~]$ dbv file=/u01/app/oracle/oradata/single2/test1.dbf blocksize=8192 DBVERIFY: Release 11.2.0.4.0 - Production on Wed Feb 17 04:23:46 2016 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/single2/test1.dbf Page 136 is marked corrupt Corrupt block relative dba: 0x01400088 (file 5, block 136) Bad header found during dbv: Data in bad block: type: 3 format: 0 rdba: 0x01400088 last change scn: 0x0000.002f7ab9 seq: 0x2 flg: 0x04 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x7ab90602 check value in block header: 0xc832 computed block checksum: 0x4a05 DBVERIFY - Verification complete Total Pages Examined : 12800 Total Pages Processed (Data) : 98 Total Pages Failing (Data) : 0 Total Pages Processed (Index): 0 Total Pages Failing (Index): 0 Total Pages Processed (Other): 136 Total Pages Processed (Seg) : 0 Total Pages Failing (Seg) : 0 Total Pages Empty : 12565 Total Pages Marked Corrupt : 1 Total Pages Influx : 0 Total Pages Encrypted : 0 Highest block SCN : 3111633 (0.3111633) 7.读取 SQL> conn test1/test1 Connected. SQL> select count(1) from testbbed; COUNT(1) ---------- 2834 SQL> alter system flush buffer_cache; System altered. SQL> select count(1) from testbbed; select count(1) from testbbed * ERROR at line 1: ORA-01578: ORACLE data block corrupted (file # 5, block # 136) ORA-01110: data file 5: '/u01/app/oracle/oradata/single2/test1.dbf' 告警日志中: ALTER SYSTEM: Flushing buffer cache Hex dump of (file 5, block 136) in trace file /u01/app/oracle/diag/rdbms/single2/single2/trace/single2_ora_2605.trc Corrupt block relative dba: 0x01400088 (file 5, block 136) Bad header found during multiblock buffer read Data in bad block: type: 3 format: 0 rdba: 0x01400088 last change scn: 0x0000.002f7ab9 seq: 0x2 flg: 0x04 spare1: 0x0 spare2: 0x0 spare3: 0x0 consistency value in tail: 0x7ab90602 check value in block header: 0xc832 computed block checksum: 0x4a05 Reading datafile '/u01/app/oracle/oradata/single2/test1.dbf' for corruption at rdba: 0x01400088 (file 5, block 136) Reread (file 5, block 136) found same corrupt data (no logical check) Wed Feb 17 04:24:45 2016 Corrupt Block Found TSN = 6, TSNAME = TEST1 RFN = 5, BLK = 136, RDBA = 20971656 OBJN = 88713, OBJD = 88713, OBJECT = TESTBBED, SUBOBJECT = SEGMENT OWNER = TEST1, SEGMENT TYPE = Table Segment Corrupt Block Found TSN = 6, TSNAME = TEST1 RFN = 5, BLK = 136, RDBA = 20971656 OBJN = 88713, OBJD = 88713, OBJECT = TESTBBED, SUBOBJECT = SEGMENT OWNER = TEST1, SEGMENT TYPE = Table Segment Errors in file /u01/app/oracle/diag/rdbms/single2/single2/trace/single2_ora_2605.trc (incident=99809): ORA-01578: ORACLE data block corrupted (file # 5, block # 136) ORA-01110: data file 5: '/u01/app/oracle/oradata/single2/test1.dbf'