本文主要是介绍【Oracle坏块】坏块类型:FRACTURED,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、模拟FRACTURED
模拟环境参考上一篇文章【Oracle坏块】Oracle坏块介绍 & 坏块类型:ALL ZERO
清除v$database_block_corruption命令:
execute dbms_backup_restore.resetCfileSection(35) -------该命令不能再pdb中执行
前期环境检查
SQL> select count(*) from test;COUNT(*) ----------20000SQL> select * from v$database_block_corruption;no rows selected ------说明当前环境没有坏块SQL> select dbms_rowid.rowid_relative_fno(rowid) rfn,dbms_rowid.rowid_block_number(rowid) bln,dbms_rowid.rowid_row_number(rowid) rn from test where rownum<=5;RFN BLN RN ---------- ---------- ----------22 131 022 131 122 131 222 131 322 131 4
模拟FRACTURED
BBED模拟,前后版本不一致(tailchk)
BBED> set file 22FILE# 22BBED> set block 131BLOCK# 131BBED> showFILE# 22BLOCK# 131OFFSET 0DBA 0x05800083 (92274819 22,131)FILENAME /u01/app/oracle/oradata/T1/pdb/test.dbfBIFILE bifile.bbdLISTFILE /u01/app/bbed_profile/bbed_filelist.txtBLOCKSIZE 8192MODE EditEDIT UnrecoverableIBASE DecOBASE DecWIDTH 80COUNT 512LOGFILE log.bbdSPOOL No
查看tailchk值
BBED> p bas_kcbh ub4 bas_kcbh @8 0x002dd509BBED> p type_kcbh ub1 type_kcbh @0 0x06BBED> p seq_kcbh ub1 seq_kcbh @14 0x01BBED> p tailchk ub4 tailchk @8188 0xd5090601------tailchk = bas_kcbh低两位字节(d509)+ type_kcbh(06)+ seq_kcbh(01) = d5090601
设置偏移量
BBED> set offset 8188OFFSET 8188BBED> d /v count 128File: /u01/app/oracle/oradata/T1/pdb/test.dbf (22)Block: 131 Offsets: 8188 to 8191 Dba:0x05800083 -------------------------------------------------------010609d5 l ...
修改tailchk
BBED> modify /x 12345678File: /u01/app/oracle/oradata/T1/pdb/test.dbf (22)Block: 131 Offsets: 8188 to 8191 Dba:0x05800083 ------------------------------------------------------------------------12345678 <32 bytes per line>BBED> sum apply Check value for File 22, Block 131: current = 0xa6eb, required = 0xa6ebBBED> d /v count 128File: /u01/app/oracle/oradata/T1/pdb/test.dbf (22)Block: 131 Offsets: 8188 to 8191 Dba:0x05800083 -------------------------------------------------------12345678 l .4Vx<16 bytes per line>BBED> p tailchk ub4 tailchk @8188 0x78563412
刷新数据库缓存查看数据
SQL> alter system flush buffer_cache;System altered.SQL> select count(*) from test; select count(*) from test* ERROR at line 1: ORA-01578: ORACLE data block corrupted (file # 22, block # 131) ORA-01110: data file 22: '/u01/app/oracle/oradata/T1/pdb/test.dbf'
发现坏块
SQL> select * from v$database_block_corruption;FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTIO CON_ID ---------- ---------- ---------- ------------------ --------- ----------22 131 1 0 FRACTURED 3
二、恢复方法
1、BBED
该类型的坏块是由tail与块头值不一致,导致数据块版本不一致
BBED> d /v count 128File: /u01/app/oracle/oradata/T1/pdb/test.dbf (22)Block: 131 Offsets: 8188 to 8191 Dba:0x05800083 -------------------------------------------------------12345678 l .4Vx<16 bytes per line>BBED> p tailchk ub4 tailchk @8188 0x78563412BBED> p kcbh struct kcbh, 20 bytes @0 ub1 type_kcbh @0 0x06ub1 frmt_kcbh @1 0xa2ub2 wrp2_kcbh @2 0x0000ub4 rdba_kcbh @4 0x05800083ub4 bas_kcbh @8 0x002dd509ub2 wrp_kcbh @12 0x0000ub1 seq_kcbh @14 0x01ub1 flg_kcbh @15 0x04 (KCBHFCKV)ub2 chkval_kcbh @16 0xa6ebub2 spare3_kcbh @18 0x0000
由上可以计算出数据块tailchk值为d5090601
由于机器低字节序的原因,所以修复使用值为010609d5
BBED> set offset 8188OFFSET 8188BBED> modify /x 010609d5File: /u01/app/oracle/oradata/T1/pdb/test.dbf (22)Block: 131 Offsets: 8188 to 8191 Dba:0x05800083 ------------------------------------------------------------------------010609d5 <32 bytes per line>BBED> sum apply Check value for File 22, Block 131: current = 0x39a7, required = 0x39a7BBED> d /v count 128File: /u01/app/oracle/oradata/T1/pdb/test.dbf (22)Block: 131 Offsets: 8188 to 8191 Dba:0x05800083 -------------------------------------------------------010609d5 l ...<16 bytes per line>
验证
SQL> alter system flush buffer_cache;System altered.SQL> select count(*) from test;COUNT(*) ----------20000
数据恢复成功
2、DBMS_REPAIR包恢复 (丢失数据)
3、CTAS方式复制(丢失数据)
4、备份恢复(不会丢数据)
以上省略,可以参照上一篇ALL ZERO的文章
这篇关于【Oracle坏块】坏块类型:FRACTURED的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!