欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

无归档情况下使用BBED处理ORA-01113错误

程序员文章站 2022-06-10 19:02:56
...

在丢失归档情况下,恢复时常会遇到ORA-01113错误,以下实验模拟表空间offline,然后在丢失归档文件的情况下使用BBED修改文件头信息

在丢失归档情况下,恢复时常会遇到ORA-01113错误,以下实验模拟表空间offline,,然后在丢失归档文件的情况下使用BBED修改文件头信息,最后恢复数据文件;
数据库版本:

SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

数据文件信息:

SQL> select file#,name, CHECKPOINT_CHANGE#,to_char(CHECKPOINT_TIME,'yyyy-mm-dd hh24:mi:ss')checkpoint_time,status,BLOCK_SIZE from v$datafile;
FILE# NAME CHECKPOINT_CHANGE# CHECKPOINT_TIME STATUS BLOCK_SIZE
---------- ----------------------------------- ------------------ ------------------- ------- ----------
1 /u01/app/oradata/sydb/system01.dbf 3161898 2015-04-13 20:46:37 SYSTEM 8192
2 /u01/app/oradata/sydb/sysaux01.dbf 3161898 2015-04-13 20:46:37 ONLINE 8192
3 /u01/app/oradata/sydb/undotbs01.dbf 3161898 2015-04-13 20:46:37 ONLINE 8192
4 /u01/app/oradata/sydb/users01.dbf 3161898 2015-04-13 20:46:37 ONLINE 8192
5 /disk2/oradata/sydb/tbs01.dbf 3161898 2015-04-13 20:46:37 ONLINE 8192
6 /disk2/oradata/sydb/tbs02.dbf 3161898 2015-04-13 20:46:37 ONLINE 8192
7 /disk2/oradata/sydb/tbs03.dbf 3161898 2015-04-13 20:46:37 ONLINE 8192
8 /tmp/tbs_tmp.dbf 3161898 2015-04-13 20:46:37 ONLINE 8192

offline数据文件7并删除归档模拟ora-01113:

SQL> alter database datafile 7 offline;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> alter database datafile 7 online;
alter database datafile 7 online
*
ERROR at line 1:
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7: '/disk2/oradata/sydb/tbs03.dbf'

SQL> select file#,change#,time from v$recover_file;
FILE# CHANGE# TIME
---------- ---------- ---------
7 3161898 13-APR-15

使用BBED需要修改的内容有:
ub4 kscnbas @484 #最后检查的SCN
ub4 kcvcptim @492 #检查时间
ub4 kcvfhcpc @140 #检查点发生次数
ub4 kcvfhccc @148 #未知,但值一直小于kcvfhcpc 1

BBED> info
File# Name Size(blks)
----- ---- ----------
1 /u01/app/oradata/sydb/system01.dbf 92160
2 /u01/app/oradata/sydb/sysaux01.dbf 71680
3 /u01/app/oradata/sydb/undotbs01.dbf 52480
4 /u01/app/oradata/sydb/users01.dbf 1600
5 /disk2/oradata/sydb/tbs01.dbf 221696
6 /disk2/oradata/sydb/tbs02.dbf 14592
7 /disk2/oradata/sydb/tbs03.dbf 2560
8 /tmp/tbs_tmp.dbf 1280

先确认好system表空间文件信息: