安装BBED工具:
11G默认不带BBED工具,需要使用10G下的几个BBED文件进行编译(同位数同操作系统类型)
ssbbded.o
sbbdpt.o
ssbbded.o
上传三个文件到11G的$ORACLE_HOME/rdbms/lib下
11G:
cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk$ORACLE_HOME/rdbms/lib/bbed
编译不报错就安装完成了
数据文件头信息:
下面两项与resetlogs相关
kcvfhrlc表示 reset logscount
kcvfhrls表示 resetlogsscn
下面四项与数据库文件scn相关
kscnbas (at offset 140) – SCN of last change to thedatafile.
kcvcptim (at offset 148) - Time of the last change to thedatafile.
kcvfhcpc (at offset 176) – Checkpoint count.
kcvfhccc (at offset 184) – Unknown, but is always 1 lessthan thecheckpoint point count.
克隆完,发现数据库里cux、spm、zs三个表空间对应的三个数据文件为offline状态,而且克隆过程中由于自动调用adcrdb.sh脚本,会重建了控制文件(自动生成的控制文件不包括这三个自定义的数据文件)及open resetlogs,导致三个文件不能recover 及online, 会出现ORA-01190或者ORA-01189之类的错误,我们通过BBED工具修改相关的数据文件头信息里的scn来达到数据文件一致来OPEN数据库.。
通过BBED修改问题数据文件头,使其SCN跟正常文件一致:
首先查看system01.dbf文件头
BBED> set filename'/u01/oracle/db/apps_st/data/system01.dbf'
FILENAME /u01/oracle/db/apps_st/data/system01.dbf
BBED> p kcvfhrlc
ub4 kcvfhrlc @112 0x39577b35
BBED> p kcvfhrls
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0xdf75ea78
ub2 kscnwrp @120 0x056c
BBED> p kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0xdf7828f7
ub2 kscnwrp @488 0x056c
ub4 kcvcptim @492 0x3958cfe1
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x00000004
ub4 kcrbabno @504 0x000402df
ub2 kcrbabof @508 0x0010
ub1 kcvcpetb[0] @512 0x02
ub1 kcvcpetb[1] @513 0x00
ub1 kcvcpetb[2] @514 0x00
ub1 kcvcpetb[3] @515 0x00
ub1 kcvcpetb[4] @516 0x00
ub1 kcvcpetb[5] @517 0x00
ub1 kcvcpetb[6] @518 0x00
ub1 kcvcpetb[7] @519 0x00
BBED> p kcvfhcpc
ub4 kcvfhcpc @140 0x00005bf6
BBED> p kcvfhccc
ub4 kcvfhccc @148 0x00005bf5
修改问题数据文件zs01.dbf,使其SCN跟system01.dbf一致:
BBED> set filename'/u01/oracle/db/apps_st/data/zs01.dbf'
FILENAME /u01/oracle/db/apps_st/data/zs01.dbf
修改kcvfhrlc:
BBED> p kcvfhrlc
ub4 kcvfhrlc @112 0x33808d1a
注:修改之前一定要先p一下,不然不能定位到该offset.
BBED> m /x 357b5739
BBED-00215: editing not allowed in BROWSEmode
BBED> set mode edit
MODE Edit
BBED> m /x 357b5739
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 112 to 623 Dba:0x00000000
------------------------------------------------------------------------
357b5739 a39432dd 6c050000 00000000 00000000 00000000 00000400 23000000
54a42739 22000000 00000000 0000000000000000 00000000 00000000 00000000
0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 8d010000
02005a53 00000000 00000000 0000000000000000 00000000 00000000 00000000
16000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 2a8c80334d7632dd 6c050000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 a48171df 6c050000 c52f5639
01000322 56000000 02000000 10000000 0200000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
<32 bytes per line>
然后再查,发现112这个偏移量的值已经修改成跟system01.dbf一致了
BBED> p kcvfhrlc
ub4 kcvfhrlc @112 0x39577b35
修改kcvfhrls:
BBED> p kcvfhrls
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0xdd3294a3
ub2 kscnwrp @120 0x056c
BBED> m /x 78ea75df
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 116 to 627 Dba:0x00000000
------------------------------------------------------------------------
78ea75df 6c05000000000000 00000000 00000000 00000400 23000000 54a42739
22000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
0000000000000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 8d010000 02005a53
00000000 00000000 00000000 00000000 0000000000000000 00000000 16000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 2a8c80334d7632dd 6c050000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 a48171df 6c050000 c52f563901000322
56000000 02000000 10000000 02000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
<32 bytes per line>
BBED> p kcvfhrls
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0xdf75ea78
ub2 kscnwrp @120 0x056c
保存:
BBED> sum
Check value for File 0, Block 1:
current = 0xd152, required = 0x5136
BBED> sum apply
Check value for File 0, Block 1:
current = 0x5136, required = 0x5136
修改kcvfhcpc:
BBED> p kcvfhcpc
ub4 kcvfhcpc @140 0x00000023
BBED> m /x f65b0000
BBED-00209: invalid number (f65b0000)
这个错误是这4个偏移量位置不接受这个值,我们只能2个偏移量一次次修改
BBED> m /x f65b
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 140 to 651 Dba:0x00000000
------------------------------------------------------------------------
f65b0000 54a4273922000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
8d010000 02005a5300000000 00000000 00000000 00000000 00000000 00000000
00000000 16000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 2a8c80334d7632dd 6c050000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 a48171df 6c050000
c52f5639 01000322 56000000 0200000010000000 02000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 0d000d00 0d000100
<32 bytes per line>
BBED> set offset+2
OFFSET 142
* 偏移量+2(140+2=142)
BBED> m /x 0000
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 142 to 653 Dba:0x00000000
------------------------------------------------------------------------
000054a4 27392200 00000000 0000000000000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00008d01
00000200 5a53000000000000 00000000 00000000 00000000 00000000 00000000
00001600 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 00002a8c 80334d76 32dd6c0500000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 0000a481 71df6c05 0000c52f
56390100 03225600 00000200 00001000 00000200 0000000000000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000d00 0d000d00 01000000
<32 bytes per line>
BBED> p kcvfhcpc
ub4 kcvfhcpc @140 0x00005bf6
修改kcvfhccc:
BBED> p kcvfhccc
ub4 kcvfhccc @148 0x00000022
BBED> m /x f55b0000
BBED-00209: invalid number (f55b0000)
理由同上
BBED> m /x f55b
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 148 to 659 Dba:0x00000000
------------------------------------------------------------------------
f55b0000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 8d010000 02005a53
00000000 00000000 00000000 00000000 0000000000000000 00000000 16000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 2a8c80334d7632dd 6c050000 0000000000000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 a48171df 6c050000 c52f563901000322
56000000 02000000 10000000 02000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0d000d000d000100 00000000 00000000
<32 bytes per line>
BBED> set offset +2
OFFSET 150
BBED> m /x 0000
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 150 to 661 Dba:0x00000000
------------------------------------------------------------------------
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000008d01 00000200 5a530000
00000000 00000000 00000000 00000000 0000000000000000 00001600 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00002a8c80334d76 32dd6c0500000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 0000a481 71df6c05 0000c52f 56390100 03225600
00000200 00001000 00000200 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000d00 0d000d0001000000 00000000 00000000
<32 bytes per line>
BBED> p kcvfhccc
ub4 kcvfhccc @148 0x00005bf5
保存:
BBED> sum
Check value for File 0, Block 1:
current = 0x5136, required = 0x5134
BBED> sum apply
Check value for File 0, Block 1:
current = 0x5134, required = 0x5134
BBED> verify
DBVERIFY - Verification starting
FILE = /u01/oracle/db/apps_st/data/zs01.dbf
BLOCK = 1
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 : 0
Total Blocks Influx : 0
Message 531 not found; product=RDBMS; facility=BBED
修改SCN:(OFFSET 484---492)
BBED> set offset 484
OFFSET 484
BBED> m /x f72878df
BBED-00209: invalid number (f72878df)
理由同上
BBED> m /x f728
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 484 to 995 Dba:0x00000000
------------------------------------------------------------------------
f72871df 6c050000 c52f5639 01000322 56000000 02000000 10000000 02000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
0d000d00 0d000100 00000000 00000000 0000000002008005 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
<32 bytes per line>
BBED> set offset +2
OFFSET 486
BBED> m /x 78df
File: /u01/oracle/db/apps_st/data/zs01.dbf (0)
Block: 1 Offsets: 486 to 997 Dba:0x00000000
------------------------------------------------------------------------
78df6c05 0000c52f 56390100 03225600 00000200 0000100000000200 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000d00
0d000d00 01000000 00000000 00000000 0000020080050000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
00000000 00000000 00000000 00000000 0000000000000000 00000000 00000000
<32 bytes per line>
BBED> p kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0xdf7828f7
ub2 kscnwrp @488 0x056c
ub4 kcvcptim @492 0x39562fc5
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x00000056
ub4 kcrbabno @504 0x00000002
ub2 kcrbabof @508 0x0010
ub1 kcvcpetb[0] @512 0x02
ub1 kcvcpetb[1] @513 0x00
ub1 kcvcpetb[2] @514 0x00
ub1 kcvcpetb[3] @515 0x00
ub1 kcvcpetb[4] @516 0x00
ub1 kcvcpetb[5] @517 0x00
ub1 kcvcpetb[6] @518 0x00
ub1 kcvcpetb[7] @519 0x00
BBED> sum
Check value for File 0, Block 1:
current = 0x5134, required = 0xf86e
BBED> sum apply
Check value for File 0, Block 1:
current = 0xf86e, required = 0xf86e
BBED>
然后再sqlplus里执行:
selectfile#,to_char(checkpoint_change#,'999999999999'),to_char(RESETLOGS_CHANGE#,'999999999999')from v$datafile_header;
发现zs01.dbf文件的scn已经一致。
Cux01.dbf,spm01.dbf执行上述步骤
然后数据库所有数据文件都一致了。
成功的恢复三个数据文件,数据没有丢失。