转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/31018075
@@@@@@@利用BBED模拟损坏5文件1号块(文件头)
BBED> copy file 4 block 4 to file 5 block 1
File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
Block: 1 Offsets: 0 to 19 Dba:0x01400001
------------------------------------------------------------------------
1ea20000 04000001 1a4b0000 00000104 99810000
<32 bytes per line>
sys@PROD> shutdown abort;
ORACLE instance shut down.
sys@PROD> starup
SP2-0042: unknown command "starup" - rest of line ignored.
sys@PROD> startup
ORACLE instance started.
Total System Global Area 939495424 bytes
Fixed Size 2233960 bytes
Variable Size 251660696 bytes
Database Buffers 679477248 bytes
Redo Buffers 6123520 bytes
Database mounted.
ORA-01122: database file 5 failed verification check
ORA-01110: data file 5: '/u01/app/oracle/oradata/PROD/tp01.dbf'
ORA-01210: data file header is media corrupt
BBED开始恢复
1、找个文件头覆盖
BBED> copy file 4 block 1 to file 5 block 1
File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
Block: 1 Offsets: 0 to 19 Dba:0x01400001
------------------------------------------------------------------------
0ba20000 01000001 00000000 00000104 edbc0000
<32 bytes per line>
2、进入5文件1号块
BBED> set file 5 block 1
FILE# 5
BLOCK# 1
(1)改块的地址5文件1号块,rdba_kcbh?
BBED> p kcvfhbfh
struct kcvfhbfh, 20 bytes @0
ub1 type_kcbh @0 0x0b
ub1 frmt_kcbh @1 0xa2
ub1 spare1_kcbh @2 0x00
ub1 spare2_kcbh @3 0x00
ub4 rdba_kcbh @4 0x01000001
ub4 bas_kcbh @8 0x00000000
ub2 wrp_kcbh @12 0x0000
ub1 seq_kcbh @14 0x01
ub1 flg_kcbh @15 0x04 (KCBHFCKV)
ub2 chkval_kcbh @16 0xbced
ub2 spare3_kcbh @18 0x0000
BBED> d /v offset 4
File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
Block: 1 Offsets: 4 to 23 Dba:0x01400001
-------------------------------------------------------
01000001 00000000 00000104 edbc0000 l ............í?..
00000000
BBED> m /x 01004001 offset 4
File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
Block: 1 Offsets: 4 to 23 Dba:0x01400001
------------------------------------------------------------------------
01004001 00000000 00000104 edbc0000 00000000
(2)文件的大小kccfhfsz?
BBED> p kcvfhhdr
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0b200000
ub4 kccfhdbi @28 0x0f302c3e
text kccfhdbn[0] @32 P
text kccfhdbn[1] @33 R
text kccfhdbn[2] @34 O
text kccfhdbn[3] @35 D
text kccfhdbn[4] @36
text kccfhdbn[5] @37
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x00000d3d
ub4 kccfhfsz @44 0x00003200
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0004
ub2 kccfhtyp @54 0x0003
ub4 kccfhacid @56 0x00000000
ub4 kccfhcks @60 0x00000000
text kccfhtag[0] @64
....................
sys@PROD> select name from v$dbfile where file#=5;
NAME
--------------------------------------------------
/u01/app/oracle/oradata/PROD/tp01.dbf
[oracle@jfdb PROD]$ ls -lFtr |grep tp01
-rw-r-----. 1 oracle oinstall 524296192 Jun 8 18:58 tp01.dbf
sys@PROD> select 524296192/8192 from dual;
524296192/8192
--------------
64001
BBED> d /v offset 44
File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
Block: 1 Offsets: 44 to 63 Dba:0x01400001
-------------------------------------------------------
00320000 00200000 04000300 00000000 l .2... ..........
00000000
BBED> m /x 00fa0000 44
File: /u01/app/oracle/oradata/PROD/t