控制文件恢复中的利用历史备份自动修复不一致

用RMAN>recover database 命令可以修复“备份控制文件中没有数据文件和表空间的信息,但实际上数据文件和表空间存在”这种问题,比如:备份了控制文件之后,新建了表空间。

一、环境:

1.备份了控制文件

2.数据库的自动控制文件备份关闭

2.增加了新的表空间数据文件

3.所有的在线控制文件损坏,没有在线镜像备份和自动备份可用

二、模拟问题环境

RMAN> connect target 

connected to target database: ORCL (DBID=1348795218)

RMAN> backup as backupset current controlfile;

Starting backup at 08-SEP-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=141 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=143 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
channel ORA_DISK_1: starting piece 1 at 08-SEP-13
channel ORA_DISK_1: finished piece 1 at 08-SEP-13
piece handle=/u01/app/oracle/product/10.2.0/db_1/dbs/u01/ora_825632989_36_1 tag=TAG20130908T222949 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 08-SEP-13

RMAN> list backup of controlfile;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
31      Full    7.05M      DISK        00:00:02     08-SEP-13      
        BP Key: 31   Status: AVAILABLE  Compressed: NO  Tag: TAG20130908T222949
        Piece Name: /u01/app/oracle/product/10.2.0/db_1/dbs/u01/ora_825632989_36_1
  Control File Included: Ckp SCN: 1966776      Ckp time: 08-SEP-13

RMAN> configure controlfile autobackup off;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored
SQL> create tablespace news datafile '/u01/app/oracle/oradata/orcl/news01.dbf' size 1M ;

Tablespace created.
[oracle@RedHat orcl]$ cp control01.ctl /u01/app/oracle/oradata/orcl/control01.ctl1
[oracle@RedHat orcl]$ cp control02.ctl /u01/app/oracle/oradata/orcl/control02.ctl1
[oracle@RedHat orcl]$ cp control03.ctl /u01/app/oracle/oradata/orcl/control03.ctl1
[oracle@RedHat orcl]$ mv control01.ctl /u01/app/oracle/oradata/control01.ctl
[oracle@RedHat orcl]$ mv control02.ctl /u01/app/oracle/oradata/control02.ctl
[oracle@RedHat orcl]$ mv control03.ctl /u01/app/oracle/oradata/control03.ctl
三、开始恢复

RMAN> restore controlfile from '/u01/app/oracle/product/10.2.0/db_1/dbs/u01/ora_825632989_36_1';

Starting restore at 08-SEP-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/u01/app/oracle/oradata/orcl/control01.ctl
output filename=/u01/app/oracle/oradata/orcl/control02.ctl
output filename=/u01/app/oracle/oradata/orcl/control03.ctl
Finished restore at 08-SEP-13
RMAN> mount database;

database mounted
released channel: ORA_DISK_1

RMAN> recover database;

Starting recover at 08-SEP-13
Starting implicit crosscheck backup at 08-SEP-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: sid=154 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 08-SEP-13

Starting implicit crosscheck copy at 08-SEP-13
using channel ORA_DISK_1
using channel ORA_DISK_2
Finished implicit crosscheck copy at 08-SEP-13

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1
using channel ORA_DISK_2

starting media recovery

archive log thread 1 sequence 132 is already on disk as file /u01/app/oracle/oradata/orcl/redo02.log
archive log filename=/u01/app/oracle/oradata/orcl/redo02.log thread=1 sequence=132
creating datafile fno=8 name=/u01/app/oracle/oradata/orcl/news01.dbf
archive log filename=/u01/app/oracle/oradata/orcl/redo02.log thread=1 sequence=132
media recovery complete, elapsed time: 00:00:03
Finished recover at 08-SEP-13
在恢复前与回复后打开数据库到mount阶段看到的数据文件内容

恢复前

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/Recovery01.dbf
/u01/app/oracle/oradata/orcl/test01.tts

7 rows selected.
恢复后

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/Recovery01.dbf
/u01/app/oracle/oradata/orcl/test01.tts
/u01/app/oracle/oradata/orcl/news01.dbf

8 rows selected.

四、最后用带有resetlogs的open命令打开数据库

SQL> alter database open resetlogs;

Database altered.




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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值