今天翻出来一篇几年前写做的 bbed 的文章。 贴在这里。 通过 bbed , 修改oracle 数据文件的 scn号, 达到数据库的不完全恢复。 抢救数据。 ------------------正文开始 ··························· 通过bbed 修改数据文件的 scn 来完成数据库的回复测试 1. oracle 9i 10g 的 unix 版本提供了 bbed 工具,但是没有编译要自己编译
> Cd $ORACLE_HOME/rdbms/lib
> make -f ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed
就会在$ORACLE_HOME/bin/ 下生成 bbed 工具。
Ip : 192.168.10.208
Os : redhat linux AS 5.4
Oracle: 10.2.0.4 64 位
Sqlplus "/ as syssba"
Sql> create tablespace test datafile '/data/oracle/oradata/testdb/TEST.dbf' size 10m;
Sql> create table test tablespace test as select * from dba_tables;
Sql > select count(*) from test;
COUNT(*)
----------
1536
Sql > Alter database datafile '/data/oracle/oradata/testdb/TEST.dbf' offline ;
Sql > alter system switch logfile ;
Sql > /
System altered.
Sql > /
System altered.
Sql > /
System altered.
Exit ;
[oracle@testdb dbs]$ cd /data/oracle/oradata/testdb/archive
[oracle@testdb archive]$ ls
1_10_700654442.dbf 1_3_700654442.dbf 1_6_700654442.dbf 1_9_700654442.dbf
1_11_700654442.dbf 1_4_700654442.dbf 1_7_700654442.dbf archive1_2_700654442.dbf
1_12_700654442.dbf 1_5_700654442.dbf 1_8_700654442.dbf
[oracle@testdb archive]$
[oracle@testdb archive.b]$ cd ..
[oracle@testdb testdb]$ ll
× Ü ¼ Æ 1826504
drwxr-xr-x 2 oracle oinstall 4096 10-20 11:56 archive
drwxr-xr-x 2 oracle oinstall 4096 10-20 10:01 archivelog
-rw-r----- 1 oracle oinstall 7389184 10-20 11:58 control01.ctl
-rw-r----- 1 oracle oinstall 7061504 10-20 10:34 control01.ctl.b
-rw-r----- 1 oracle oinstall 7389184 10-20 11:58 control02.ctl
-rw-r----- 1 oracle oinstall 7061504 10-20 10:34 control02.ctl.b
-rw-r----- 1 oracle oinstall 7389184 10-20 11:58 control03.ctl
-rw-r----- 1 oracle oinstall 7061504 10-20 10:34 control03.ctl.b
-rw-r----- 1 oracle oinstall 104858112 10-20 11:56 redo01.log
-rw-r----- 1 oracle oinstall 104858112 10-20 11:58 redo02.log
-rw-r----- 1 oracle oinstall 104858112 10-20 11:37 redo03.log
-rw-r----- 1 oracle oinstall 262152192 10-20 11:54 sysaux01.dbf
-rw-r----- 1 oracle oinstall 503324672 10-20 11:57 system01.dbf
-rw-r----- 1 oracle oinstall 503324672 10-20 10:41 system01.dbf.b
-rw-r----- 1 oracle oinstall 20979712 10-19 22:00 temp01.dbf
-rw-r----- 1 oracle oinstall 104865792 10-20 11:37 TEST.dbf
-rw-r----- 1 oracle oinstall 104865792 10-20 10:42 TEST.dbf.b
-rw-r----- 1 oracle oinstall 26222592 10-20 11:57 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 10-20 11:37 users01.dbf
把归档日志转移造成数据问题件无法online
[oracle@testdb testdb]$ mv archive archive.b
[oracle@testdb testdb]$ ls archive.b/
1_10_700654442.dbf 1_3_700654442.dbf 1_6_700654442.dbf 1_9_700654442.dbf
1_11_700654442.dbf 1_4_700654442.dbf 1_7_700654442.dbf archive1_2_700654442.dbf
1_12_700654442.dbf 1_5_700654442.dbf 1_8_700654442.dbf
SQL*Plus: Release 10.2.0.4.0 - Production on ÐÇÆÚ ¶ þ 10ÔÂ 20 10:28:19 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database datafile '/data/oracle/oradata/testdb/TEST.dbf' online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/data/oracle/oradata/testdb/TEST.dbf'
SQL> ORA-00283: recovery session canceled due to errors
ORA-01124: cannot recover data file 1 - file is in use or recovery
ORA-01110: data file 1: '/data/oracle/oradata/testdb/system01.dbf'
Sql > shutdown immediate ;
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
数据文件无法online 了,因为数据库在对数据文件做 online 的时候是不修改文件头的,只修改 controlfile 的 状态或者 scn 然后再数据文件 online 的时候执行恢复操作 .
这里直接改 datafile 的 datafile header 中的 checkpoint scn 和 RBA 是不行的!
因为 oracle 在对某个 datafile 做 offline 的时候实际上是相当于 offline immediate ,此时不会改 datafile header 中的内容,而只是修改 control 文件,等到再想 online 的时候一定要做 recovery ,对这一点, 403e 也有描述:
Offline normal (tablespace) :
1 、 Checkpoints data blocks of tablespace
2 、 Updates file headers and control file
Offline immediate (tablespace or data file) :
1 、 Only update control file
2 、 Data files require recovery
BBED 无法改 control 文件,所以上述这条只改 datafile header 中的 checkpoint scn 和 RBA 的路是走不通的。
这里我采取的方法是先改 datafile header ,再重建控制文件,即可强制恢复 offline 状态的 datafile ,在修改上述 offline 的 datafile header 的过程中我是通过比对 system01.dbf 的 datafile header 来修改 offline datafile 的 datafile header ,完整的恢复过程可见附带的文件 session.log
其中重要的步骤如下:
1 、 先通过比对 system01.dbf 的 datafile header 的内容来修改 datafile TEST.dbf 的 datafile header 。
2 、 重建控制文件
3 、 用带 *._allow_resetlogs_corruption=TRUE 的 pfile 启库到 mount 状态
4 、 用 open resetlogs 强制打开上述数据库
5 、 最后 shutdown immediate 再 startup
[oracle@testdb ~]$ more par.bbd
1 /data/oracle/oradata/testdb/system01.dbf 503324672
2 /data/oracle/oradata/testdb/TEST.dbf 104865792
[oracle@testdb ~]$
[oracle@testdb ~]$ (bbed listfile=par.bbd) |tee test1.log
Password:
Bbed 修改数据文件 TEST.dbf 文件头的 scn
Password:
BBED: Release 2.0.0.0.0 - Limited Production on 星期二 10 月 20 12:10:26 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set FILE# 1
BBED> set BLOCK# 1
BBED> set FILE# 1
BBED> SHOW
BLOCK# 1
OFFSET 0
DBA 0x00400001 (4194305 1,1)
FILENAME /data/oracle/oradata/testdb/ystem01.dbf
BIFILE bifile.bbd
LISTFILE par.bbd
BLOCKSIZE 8192
MODE Browse
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
BBED> map
File: /data/oracle/oradata/testdb/ystem01.dbf(1)
Block: 1 Dba:0x00400001
------------------------------------------------------------
Data File Header
struct kcvfh, 676 bytes @0
ub4 tailchk @8188
BBED> p kcvfh
struct kcvfh, 676 bytes @0
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 0x00400001
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 0xe92a
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0a200300
ub4 kccfhdbi @28 0x940e90e7
text kccfhdbn[0] @32 T
text kccfhdbn[1] @33 E
text kccfhdbn[2] @34 S
text kccfhdbn[3] @35 T
text kccfhdbn[4] @36 D
text kccfhdbn[5] @37 B
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0xd201002a
ub4 kccfhfsz @44 0x0000f000
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0001
ub2 kccfhtyp @54 0x0003
ub4 kccfhacid @56 0x00000000
ub4 kccfhcks @60 0x00000000
text kccfhtag[0] @64
text kccfhtag[1] @65
text kccfhtag[2] @66
text kccfhtag[3] @67
text kccfhtag[4] @68
text kccfhtag[5] @69
text kccfhtag[6] @70
text kccfhtag[7] @71
text kccfhtag[8] @72
text kccfhtag[9] @73
text kccfhtag[10] @74
text kccfhtag[11] @75
text kccfhtag[12] @76
text kccfhtag[13] @77
text kccfhtag[14] @78
text kccfhtag[15] @79
text kccfhtag[16] @80
text kccfhtag[17] @81
text kccfhtag[18] @82
text kccfhtag[19] @83
text kccfhtag[20] @84
text kccfhtag[21] @85
text kccfhtag[22] @86
text kccfhtag[23] @87
text kccfhtag[24] @88
text kccfhtag[25] @89
text kccfhtag[26] @90
text kccfhtag[27] @91
text kccfhtag[28] @92
text kccfhtag[29] @93
text kccfhtag[30] @94
text kccfhtag[31] @95
ub4 kcvfhrdb @96 0x00400179
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000005
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x26b0deac
ub4 kcvfhrlc @112 0x29c48816
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x000a7164
ub2 kscnwrp @120 0x0000
ub4 kcvfhbti @124 0x00000000
struct kcvfhbsc, 8 bytes @128
ub4 kscnbas @128 0x00000000
ub2 kscnwrp @132 0x0000
ub2 kcvfhbth @136 0x0000
ub2 kcvfhsta @138 0x2004 (KCVFHOFZ)
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x000a764a
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x29c48cdd
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x00000002
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
ub4 kcvfhcpc @140 0x00000049
ub4 kcvfhrts @144 0x29c486bf
ub4 kcvfhccc @148 0x00000048
struct kcvfhbcp, 36 bytes @152
struct kcvcpscn, 8 bytes @152
ub4 kscnbas @152 0x00000000
ub2 kscnwrp @156 0x0000
ub4 kcvcptim @160 0x00000000
ub2 kcvcpthr @164 0x0000
union u, 12 bytes @168
struct kcvcprba, 12 bytes @168
ub4 kcrbaseq @168 0x00000000
ub4 kcrbabno @172 0x00000000
ub2 kcrbabof @176 0x0000
ub1 kcvcpetb[0] @180 0x00
ub1 kcvcpetb[1] @181 0x00
ub1 kcvcpetb[2] @182 0x00
ub1 kcvcpetb[3] @183 0x00
ub1 kcvcpetb[4] @184 0x00
ub1 kcvcpetb[5] @185 0x00
ub1 kcvcpetb[6] @186 0x00
ub1 kcvcpetb[7] @187 0x00
ub4 kcvfhbhz @312 0x00000000
struct kcvfhxcd, 16 bytes @316
ub4 space_kcvmxcd[0] @316 0x00000000
ub4 space_kcvmxcd[1] @320 0x00000000
ub4 space_kcvmxcd[2] @324 0x00000000
ub4 space_kcvmxcd[3] @328 0x00000000
word kcvfhtsn @332 0
ub2 kcvfhtln @336 0x0006
text kcvfhtnm[0] @338 S
text kcvfhtnm[1] @339 Y
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 T
text kcvfhtnm[4] @342 E
text kcvfhtnm[5] @343 M
text kcvfhtnm[6] @344
text kcvfhtnm[7] @345
text kcvfhtnm[8] @346
text kcvfhtnm[9] @347
text kcvfhtnm[10] @348
text kcvfhtnm[11] @349
text kcvfhtnm[12] @350
text kcvfhtnm[13] @351
text kcvfhtnm[14] @352
text kcvfhtnm[15] @353
text kcvfhtnm[16] @354
text kcvfhtnm[17] @355
text kcvfhtnm[18] @356
text kcvfhtnm[19] @357
text kcvfhtnm[20] @358
text kcvfhtnm[21] @359
text kcvfhtnm[22] @360
text kcvfhtnm[23] @361
text kcvfhtnm[24] @362
text kcvfhtnm[25] @363
text kcvfhtnm[26] @364
text kcvfhtnm[27] @365
text kcvfhtnm[28] @366
text kcvfhtnm[29] @367
ub4 kcvfhrfn @368 0x00000001
struct kcvfhrfs, 8 bytes @372
ub4 kscnbas @372 0x00000000
ub2 kscnwrp @376 0x0000
ub4 kcvfhrft @380 0x00000000
struct kcvfhafs, 8 bytes @384
ub4 kscnbas @384 0x00000000
ub2 kscnwrp @388 0x0000
ub4 kcvfhbbc @392 0x00000000
ub4 kcvfhncb @396 0x00000000
ub4 kcvfhmcb @400 0x00000000
ub4 kcvfhlcb @404 0x00000000
ub4 kcvfhbcs @408 0x00000000
ub2 kcvfhofb @412 0x000a
ub2 kcvfhnfb @414 0x000a
ub4 kcvfhprc @416 0x29c3236a
struct kcvfhprs, 8 bytes @420
ub4 kscnbas @420 0x000932c5
ub2 kscnwrp @424 0x0000
struct kcvfhprfs, 8 bytes @428
ub4 kscnbas @428 0x00000000
ub2 kscnwrp @432 0x0000
ub4 kcvfhtrt @444 0x00000000
BBED> set FILE# 2
BBED> set BLOCK# 1
BBED> set FILE# 2
BBED> SHOW
BLOCK# 1
OFFSET 0
DBA 0x00800001 (8388609 2,1)
FILENAME /home/oracle/TEST.dbf
BIFILE bifile.bbd
LISTFILE par.bbd
BLOCKSIZE 8192
MODE Browse
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
BBED> MAP
File: /home/oracle/TEST.dbf (2)
Block: 1 Dba:0x00800001
------------------------------------------------------------
Data File Header
struct kcvfh, 676 bytes @0
ub4 tailchk @8188
BBED> p kcvfh
struct kcvfh, 676 bytes @0
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 0x01400001
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 0xea92
ub2 spare3_kcbh @18 0x0000
struct kcvfhhdr, 76 bytes @20
ub4 kccfhswv @20 0x00000000
ub4 kccfhcvn @24 0x0a200300
ub4 kccfhdbi @28 0x940e90e7
text kccfhdbn[0] @32 T
text kccfhdbn[1] @33 E
text kccfhdbn[2] @34 S
text kccfhdbn[3] @35 T
text kccfhdbn[4] @36 D
text kccfhdbn[5] @37 B
text kccfhdbn[6] @38
text kccfhdbn[7] @39
ub4 kccfhcsq @40 0x000001a1
ub4 kccfhfsz @44 0x00003200
s_blkz kccfhbsz @48 0x00
ub2 kccfhfno @52 0x0005
ub2 kccfhtyp @54 0x0003
ub4 kccfhacid @56 0x00000000
ub4 kccfhcks @60 0x00000000
text kccfhtag[0] @64
text kccfhtag[1] @65
text kccfhtag[2] @66
text kccfhtag[3] @67
text kccfhtag[4] @68
text kccfhtag[5] @69
text kccfhtag[6] @70
text kccfhtag[7] @71
text kccfhtag[8] @72
text kccfhtag[9] @73
text kccfhtag[10] @74
text kccfhtag[11] @75
text kccfhtag[12] @76
text kccfhtag[13] @77
text kccfhtag[14] @78
text kccfhtag[15] @79
text kccfhtag[16] @80
text kccfhtag[17] @81
text kccfhtag[18] @82
text kccfhtag[19] @83
text kccfhtag[20] @84
text kccfhtag[21] @85
text kccfhtag[22] @86
text kccfhtag[23] @87
text kccfhtag[24] @88
text kccfhtag[25] @89
text kccfhtag[26] @90
text kccfhtag[27] @91
text kccfhtag[28] @92
text kccfhtag[29] @93
text kccfhtag[30] @94
text kccfhtag[31] @95
ub4 kcvfhrdb @96 0x00000000
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x0009dd40
ub2 kscnwrp @104 0x0000
ub4 kcvfhcrt @108 0x29c37de2
ub4 kcvfhrlc @112 0x29c3236a
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x000932c5
ub2 kscnwrp @120 0x0000
ub4 kcvfhbti @124 0x00000000
struct kcvfhbsc, 8 bytes @128
ub4 kscnbas @128 0x00000000
ub2 kscnwrp @132 0x0000
ub2 kcvfhbth @136 0x0000
ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x000a6bd9
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x29c471dc
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x00000002
ub4 kcrbabno @504 0x00016142
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
ub4 kcvfhcpc @140 0x00000005
ub4 kcvfhrts @144 0x00000000
ub4 kcvfhccc @148 0x00000004
struct kcvfhbcp, 36 bytes @152
struct kcvcpscn, 8 bytes @152
ub4 kscnbas @152 0x00000000
ub2 kscnwrp @156 0x0000
ub4 kcvcptim @160 0x00000000
ub2 kcvcpthr @164 0x0000
union u, 12 bytes @168
struct kcvcprba, 12 bytes @168
ub4 kcrbaseq @168 0x00000000
ub4 kcrbabno @172 0x00000000
ub2 kcrbabof @176 0x0000
ub1 kcvcpetb[0] @180 0x00
ub1 kcvcpetb[1] @181 0x00
ub1 kcvcpetb[2] @182 0x00
ub1 kcvcpetb[3] @183 0x00
ub1 kcvcpetb[4] @184 0x00
ub1 kcvcpetb[5] @185 0x00
ub1 kcvcpetb[6] @186 0x00
ub1 kcvcpetb[7] @187 0x00
ub4 kcvfhbhz @312 0x00000000
struct kcvfhxcd, 16 bytes @316
ub4 space_kcvmxcd[0] @316 0x00000000
ub4 space_kcvmxcd[1] @320 0x00000000
ub4 space_kcvmxcd[2] @324 0x00000000
ub4 space_kcvmxcd[3] @328 0x00000000
word kcvfhtsn @332 6
ub2 kcvfhtln @336 0x0004
text kcvfhtnm[0] @338 T
text kcvfhtnm[1] @339 E
text kcvfhtnm[2] @340 S
text kcvfhtnm[3] @341 T
text kcvfhtnm[4] @342
text kcvfhtnm[5] @343
text kcvfhtnm[6] @344
text kcvfhtnm[7] @345
text kcvfhtnm[8] @346
text kcvfhtnm[9] @347
text kcvfhtnm[10] @348
text kcvfhtnm[11] @349
text kcvfhtnm[12] @350
text kcvfhtnm[13] @351
text kcvfhtnm[14] @352
text kcvfhtnm[15] @353
text kcvfhtnm[16] @354
text kcvfhtnm[17] @355
text kcvfhtnm[18] @356
text kcvfhtnm[19] @357
text kcvfhtnm[20] @358
text kcvfhtnm[21] @359
text kcvfhtnm[22] @360
text kcvfhtnm[23] @361
text kcvfhtnm[24] @362
text kcvfhtnm[25] @363
text kcvfhtnm[26] @364
text kcvfhtnm[27] @365
text kcvfhtnm[28] @366
text kcvfhtnm[29] @367
ub4 kcvfhrfn @368 0x00000005
struct kcvfhrfs, 8 bytes @372
ub4 kscnbas @372 0x00000000
ub2 kscnwrp @376 0x0000
ub4 kcvfhrft @380 0x00000000
struct kcvfhafs, 8 bytes @384
ub4 kscnbas @384 0x00000000
ub2 kscnwrp @388 0x0000
ub4 kcvfhbbc @392 0x00000000
ub4 kcvfhncb @396 0x00000000
ub4 kcvfhmcb @400 0x00000000
ub4 kcvfhlcb @404 0x00000000
ub4 kcvfhbcs @408 0x00000000
ub2 kcvfhofb @412 0x0000
ub2 kcvfhnfb @414 0x0000
ub4 kcvfhprc @416 0x26b0de91
struct kcvfhprs, 8 bytes @420
ub4 kscnbas @420 0x00000001
ub2 kscnwrp @424 0x0000
struct kcvfhprfs, 8 bytes @428
ub4 kscnbas @428 0x00000000
ub2 kscnwrp @432 0x0000
ub4 kcvfhtrt @444 0x00000000
注: 我们对比 TEST.dbf 和 system01.dbf 文件头中 scn 的差异然后修改 TEST.dbf 文件的文件的 scn
BBED> set OFFSET 40
BBED> dump
File: /data/oracle/oradta/testdb /TEST.dbf (2)
Block: 1 Offsets: 40 to 551 Dba:0x00800001
------------------------------------------------------------------------
a1010000 00320000 00200000 05000300 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 40dd0900
00000000 e27dc329 6a23c329 c5320900 00000000 00000000 00000000 00000000
00000400 05000000 00000000 04000000 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 06000000 04005445 53540000 00000000 00000000 00000000 00000000
00000000 00000000 05000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 91deb026 01000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 d96b0a00
00000a00 dc71c429 01000000 02000000 42610100 10000000 02000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> set MODE Edit
BBED> modiby /x 000001d2
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y
. File: /data/oracle/oradta/testdb /TEST.dbf(2)
Block: 1 Offsets: 40 to 551 Dba:0x00800001
------------------------------------------------------------------------
000001d2 00320000 00200000 05000300 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 40dd0900
00000000 e27dc329 6a23c329 c5320900 00000000 00000000 00000000 00000000
00000400 05000000 00000000 04000000 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 06000000 04005445 53540000 00000000 00000000 00000000 00000000
00000000 00000000 05000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 91deb026 01000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 d96b0a00
00000a00 dc71c429 01000000 02000000 42610100 10000000 02000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> set OFFSET 484
BBED> dump
File: /data/oracle/oradta/testdb /TEST.dbf(2)
Block: 1 Offsets: 484 to 995 Dba:0x00800001
------------------------------------------------------------------------
d96b0a00 00000a00 dc71c429 01000000 02000000 42610100 10000000 02000000
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
0d000d00 0d000100 00000000 00000000 00000000 02004001 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 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> modiby /x 000a7163
File: /data/oracle/oradta/testdb /TEST.dbf(2)
Block: 1 Offsets: 484 to 995 Dba:0x00800001
------------------------------------------------------------------------
000a7163 00000a00 dc71c429 01000000 02000000 42610100 10000000 02000000
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
0d000d00 0d000100 00000000 00000000 00000000 02004001 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 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED>
BBED> set OFFSET 492
BBED> dump
/data/oracle/oradta/testdb /TEST.dbf(2)
Block: 1 Offsets: 492 to 1003 Dba:0x00800001
------------------------------------------------------------------------
dc71c429 01000000 02000000 42610100 10000000 02000000 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 0d000d00 0d000100
00000000 00000000 00000000 02004001 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 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> modify /x 29c479ad
File: /data/oracle/oradta/testdb /TEST.dbf(2)
Block: 1 Offsets: 492 to 1003 Dba:0x00800001
------------------------------------------------------------------------
29c479ad 01000000 02000000 42610100 10000000 02000000 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 0d000d00 0d000100
00000000 00000000 00000000 02004001 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 00000000 00000000 00000000 00000000 00000000 00000000
<32 bytes per line>
BBED> sum apply
Check value for File 2, Block 1:
current = 0x0ad8, required = 0x0ad8
BBED> exit
重建控制文件 :
SQL*Plus: Release 10.2.0.4.0 - Production on 星期二 10 月 20 11:27:55 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
Sql > startup nomount ;
SQL> ORACLE instance started.
Total System Global Area 1.2012E+10 bytes
Fixed Size 2104248 bytes
Variable Size 1677722696 bytes
Database Buffers 1.0318E+10 bytes
Redo Buffers 14671872 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "TESTDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/data/oracle/oradata/testdb/redo01.log' SIZE 100M,
GROUP 2 '/data/oracle/oradata/testdb/redo02.log' SIZE 100M,
GROUP 3 '/data/oracle/oradata/testdb/redo03.log' SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'/data/oracle/oradata/testdb/system01.dbf',
'/data/oracle/oradata/testdb/undotbs01.dbf',
'/data/oracle/oradata/testdb/sysaux01.dbf',
'/data/oracle/oradata/testdb/users01.dbf',
'/data/oracle/oradata/testdb/TEST.dbf'
CHARACTER SET ZHS16GBK
;
SQL> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Control file created.
SQL> alter database mount
*
ERROR at line 1:
ORA-01100: database already mounted
SQL> alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlog
*
ERROR at line 1:
ORA-02288: invalid OPEN mode
SQL> alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/data/oracle/oradata/testdb/system01.dbf'
SQL> recover database using backup controlfle until cancel ;
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Auto
ORA-00308: cannot open archived log
'/data/oracle/oradata/testdb/archive/1_13_700654442.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00308: cannot open archived log
'/data/oracle/oradata/testdb/archive/1_13_700654442.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 5 needs more recovery to be consistent
ORA-01110: data file 5: '/data/oracle/oradata/testdb/TEST.dbf'
SQL> alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 5 needs more recovery to be consistent
ORA-01110: data file 5: '/data/oracle/oradata/testdb/TEST.dbf'
SQL>
CURR_SEQ
---------
0
0
0
SQL> shutdown immediate ;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
修改pfile 加入 隐含参数
*._allow_resetlogs_corruption=TRUE
Vi inittestdb.ora
testdb.__db_cache_size=10317987840
testdb.__java_pool_size=16777216
testdb.__large_pool_size=16777216
testdb.__shared_pool_size=1644167168
testdb.__streams_pool_size=0
*.audit_file_dest='/data/oracle/admin/testdb/adump'
*.background_dump_dest='/data/oracle/admin/testdb/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/data/oracle/oradata/testdb/control01.ctl','/data/oracle/oradata/testdb/control02.ctl','/data/oracle/oradata/testdb/control03.ctl'
*.core_dump_dest='/data/oracle/admin/testdb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='testdb'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=testdbXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/data/oracle/oradata/testdb/archive'
*.open_cursors=300
*.pga_aggregate_target=1671430144
*.processes=2000
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=2205
*.sga_max_size=12000000000
*.sga_target=12000000000
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/data/oracle/admin/testdb/udump'
*._allow_resetlogs_corruption=TRUE
SQL>startup mount pfile ='/data/oracle/product/10.2.0/dbs/inittestdb.ora';
ORACLE instance started.
Total System Global Area 1.2012E+10 bytes
Fixed Size 2104248 bytes
Variable Size 1677722696 bytes
Database Buffers 1.0318E+10 bytes
Redo Buffers 14671872 bytes
Database mounted.
SQL> alter database open resetlogs
Database altered.
SQL> select count(*) from test;
COUNT(*)
----------
1536
SQL> shutdown immediate;
SQL> Database closed.
Database dismounted.
ORACLE instance shut down.
Sql > startup open
SQL> ORACLE instance started.
Total System Global Area 1.2012E+10 bytes
Fixed Size 2104248 bytes
Variable Size 1677722696 bytes
Database Buffers 1.0318E+10 bytes
Redo Buffers 14671872 bytes
Database mounted.
Database opened.
SQL> select count(*) from test;
COUNT(*)
----------
1536
SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
OK 到此为止,数据文件已经可以读出来了,里面的数据也可以抢救出来了,
演示的比较简单,在某些特殊环境下,可以抢救某些表空间里的数据.
