利用BBED修改数据块SCN----极端环境下的数据恢复



破坏system表空间文件  ----比较暴力做前需做好备份
cd $ORACLE_BASE/oradata/PROD1

cp system01.dbf system01.dbf.bak
切日志模拟生产交易,更新SCN

SYS@PROD1 > alter system switch logfile;
多切几次
SYS@PROD1 > /

System altered.

SYS@PROD1 > /

System altered.

把旧的system文件直接复制替换掉新的

cp system01.dbf.bak system01.dbf

再次切日志模拟生产交易
SYS@PROD1 > alter system switch logfile;
多切几次
SYS@PROD1 > /

System altered.

SYS@PROD1 > /

System altered.
/
alter system switch logfile
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 25597
Session ID: 24 Serial number: 887
出现问题,数据库直接宕掉

SYS@PROD1 > ERROR:
ORA-03114: not connected to ORACLE


SYS@PROD1 > conn / as sysdba
Connected.
SYS@PROD1 > select status from v$instance;
ERROR:
ORA-01012: not logged on

SYS@PROD1 > conn / as sysdba


SYS@PROD1 > startup
ORACLE instance started.

Total System Global Area 313860096 bytes
Fixed Size 1344652 bytes
Variable Size 260049780 bytes
Database Buffers 46137344 bytes
Redo Buffers 6328320 bytes
Database mounted.
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD1/system01.dbf'


SYS@PROD1 > col name for a50
SYS@PROD1 > select name,checkpoint_change# from v$datafile;

NAME CHECKPOINT_CHANGE#
-------------------------------------------------- ------------------
/u01/app/oracle/oradata/PROD1/system01.dbf 1199315
/u01/app/oracle/oradata/PROD1/sysaux01.dbf 1199315
/u01/app/oracle/oradata/PROD1/undotbs01.dbf 1199315
/u01/app/oracle/oradata/PROD1/users01.dbf 1199315
/u01/app/oracle/oradata/PROD1/example01.dbf 1199315


scn转换成16进制
SYS@PROD1 > select to_char(1199315,'xxxxxxxx') from dual;


TO_CHAR(1
---------
124cd3



SYS@PROD1 > select name,checkpoint_change# from v$datafile_header;

NAME CHECKPOINT_CHANGE#
-------------------------------------------------- ------------------
/u01/app/oracle/oradata/PROD1/system01.dbf 1191817
/u01/app/oracle/oradata/PROD1/sysaux01.dbf 1199315
/u01/app/oracle/oradata/PROD1/undotbs01.dbf 1199315
/u01/app/oracle/oradata/PROD1/users01.dbf 1199315
/u01/app/oracle/oradata/PROD1/example01.dbf 1199315


可以看到数据库users01.dbf的scn点为1191817明显是用的备份的数据文件。oracle在open数据库时要对控制文件,数据文件头的scn进行检查,一致才能打开,所以这里我们通过ddeb来修改数据文件头让它和其他的数据文件的scn相同,达到起库的目的。



[oracle@guo ~]$ bbed parfile=bbed.par
Password:

BBED: Release 2.0.0.0.0 - Limited Production on Tue May 19 10:52:04 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

用bbed查询bbed01数据文件结构信息
BBED> set dba 1,1
DBA 0x00400001 (4194305 1,1)

Bbed查看kcvfh信息
BBED> p kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x00122f89
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x34754da5
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x0000001e
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> set filename '/u01/app/oracle/oradata/PROD1/system01.dbf'
FILENAME /u01/app/oracle/oradata/PROD1/system01.dbf

BBED> p kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x00122f89
ub2 kscnwrp @488 0x0000
ub4 kcvcptim @492 0x34754da5
ub2 kcvcpthr @496 0x0001
union u, 12 bytes @500
struct kcvcprba, 12 bytes @500
ub4 kcrbaseq @500 0x0000001e
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> d /v dba 4,1 offset 484
File: /u01/app/oracle/oradata/PROD1/users01.dbf (4)
Block: 1 Offsets: 484 to 995 Dba:0x01000001
-------------------------------------------------------
d34c1200 0000ae31 c9607534 0100af31 l ?L....?1?`u4..?1
29000000 02000000 10000000 02000000 l )...............
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
0a000a00 0a000100 00000000 00000000 l ................
00000000 02000001 03000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................

<16 bytes per line>
system文件头
BBED> d /v dba 1,1 offset 484
File: /u01/app/oracle/oradata/PROD1/system01.dbf (1)
Block: 1 Offsets: 484 to 995 Dba:0x00400001
-------------------------------------------------------
892f1200 000089bf a54d7534 01000000 l ./.....??Mu4....
1e000000 02000000 10000000 02000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
0a000a00 0a000100 00000000 00000000 l ................
00000000 02004000 72fc0b00 00000000 l ......@.r?......
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 024c6582 l .............Le.
d61636a4 7acf3f5d 13b1e763 d0000000 l ?.6?z??].??c?...
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00173356 l ..............3V
1c4cd306 46040f87 3704db71 a6210600 l .L?.F...7.?q?!..
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................

<16 bytes per line>
修改system文件头
BBED> modify /x d34c1200 dba 1,1 offset 484
BBED-00209: invalid number (d34c1200)


BBED> sum dba 1,1 apply
Check value for File 1, Block 1:
current = 0x6d23, required = 0x6d23

BBED> d /v dba 1,1 offset 484
File: /u01/app/oracle/oradata/PROD1/system01.dbf (1)
Block: 1 Offsets: 484 to 995 Dba:0x00400001
-------------------------------------------------------
892f1200 000089bf a54d7534 01000000 l ./.....??Mu4....
1e000000 02000000 10000000 02000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
0a000a00 0a000100 00000000 00000000 l ................
00000000 02004000 72fc0b00 00000000 l ......@.r?......
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 024c6582 l .............Le.
d61636a4 7acf3f5d 13b1e763 d0000000 l ?.6?z??].??c?...
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00173356 l ..............3V
1c4cd306 46040f87 3704db71 a6210600 l .L?.F...7.?q?!..
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................

<16 bytes per line>

BBED> modify /x d34c1200 dba 1,1 offset 484
BBED-00209: invalid number (d34c1200)


BBED> modify /x d34c1200 dba 1,1 offset 484
BBED-00209: invalid number (d34c1200)


BBED> d /v dba 2,1 offset 484
File: /u01/app/oracle/oradata/PROD1/sysaux01.dbf (2)
Block: 1 Offsets: 484 to 995 Dba:0x00800001
-------------------------------------------------------
d34c1200 0000ae31 c9607534 0100af31 l ?L....?1?`u4..?1
29000000 02000000 10000000 02000000 l )...............
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
0a000a00 0a000100 00000000 00000000 l ................
00000000 02008000 5c040c00 00000000 l ........\.......
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................

<16 bytes per line>



BBED> modify /x d34c1200 dba 1,1 offset 484
BBED-00209: invalid number (d34c1200)


完整16进制提示无效d34c1200,不知道为什么
BBED> modify /x d34c dba 1,1 offset 484  (填写部分,字母前的)
File: /u01/app/oracle/oradata/PROD1/system01.dbf (1)
Block: 1 Offsets: 484 to 995 Dba:0x00400001
------------------------------------------------------------------------
d34c1200 000089bf a54d7534 01000000 1e000000 02000000 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
0a000a00 0a000100 00000000 00000000 00000000 02004000 72fc0b00 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 024c6582 d61636a4 7acf3f5d 13b1e763 d0000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00173356
1c4cd306 46040f87 3704db71 a6210600 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
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 dba 1,1 apply
Check value for File 1, Block 1:
current = 0x0e79, required = 0x0e79

BBED> d /v dba 1,1 offset 484
File: /u01/app/oracle/oradata/PROD1/system01.dbf (1)
Block: 1 Offsets: 484 to 995 Dba:0x00400001
-------------------------------------------------------
d34c1200 000089bf a54d7534 01000000 l ?L.....??Mu4....
1e000000 02000000 10000000 02000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
0a000a00 0a000100 00000000 00000000 l ................
00000000 02004000 72fc0b00 00000000 l ......@.r?......
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 024c6582 l .............Le.
d61636a4 7acf3f5d 13b1e763 d0000000 l ?.6?z??].??c?...
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00173356 l ..............3V
1c4cd306 46040f87 3704db71 a6210600 l .L?.F...7.?q?!..
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................
00000000 00000000 00000000 00000000 l ................

<16 bytes per line>

BBED>


SYS@PROD1 > alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD1/system01.dbf'


SYS@PROD1 > recover database;
Media recovery complete.
SYS@PROD1 > alter database open;

Database altered.

















来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24742969/viewspace-1662201/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24742969/viewspace-1662201/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值