Oracle 穿越incarnation恢复数据(一)

2014-11-24 11:46:47 · 作者: · 浏览: 2

当进行不完全恢复后,可能没达到恢复的要求,这个时候数据库已经被resetlogs方式打开过了,如果在进行不完全恢复前没有对数据库进行全库备份,这个时候又想恢复上一个incarnation的某些数据,在这种场景下就需要进行incarnation穿越,下面来演示下这个场景!
一:准备实验基础数据
SQL> create table t043_incarnation(a varchar2(20)) tablespace example;
Table created.

SQL> insert into t043_incarnation values ('corss successful');
1 row created.

SQL> commit;
Commit complete.

SQL> create table t043_other (a number) tablespace example;
Table created.

SQL> insert into t043_other values (1);
1 row created.

SQL> insert into t043_other values (2);
1 row created.

SQL> commit;
Commit complete.

SQL> alter system switch logfile;
System altered.

SQL> insert into t043_other values (3);
1 row created.

SQL> alter system switch logfile;
System altered.

SQL> select sysdate from dual;

SYSDATE
-------------------
2011-07-17-21:22:30

SQL> truncate table t043_incarnation;
Table truncated.

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 64
Next log sequence to archive 66
Current log sequence 66
SQL> insert into t043_other values (4);
1 row created.

SQL> commit;
Commit complete.

SQL> alter system switch logfile;
System altered.

SQL> insert into t043_other values (5);
1 row created.

SQL> alter system switch logfile;
System altered.

SQL> commit;
Commit complete.

SQL> alter system switch logfile;
System altered.
二:删除全部控制文件第67号归档日志文件,这样进行恢复的时候就必须进行不完全恢复
[oracle@rhel6 2011_07_17]$ pwd
/u01/app/flash_recovery_area/ORA10G/archivelog/2011_07_17
[oracle@rhel6 2011_07_17]$ rm -i o1_mf_1_67_725rmcx1_.arc
rm: remove regular file `o1_mf_1_67_725rmcx1_.arc' y
[oracle@rhel6 2011_07_17]$ rm -rf /u01/app/oradata/ora10g/control0*

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 629145600 bytes
Fixed Size 2022824 bytes
Variable Size 205521496 bytes
Database Buffers 415236096 bytes
Redo Buffers 6365184 bytes
ORA-00205: error in identifying control file, check alert log for more info
三:使用控制文件二进制自动备份进行恢复,也可以使用trace脚本,由于归档日志丢失的原因,都需要进行不完全恢复
RMAN> restore controlfile from autobackup;
Starting restore at 2011-07-17-21:28:29
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=154 devtype=DISK

recovery area destination: /u01/app/flash_recovery_area
database name (or database unique name) used for search: ORA10G
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/app/flash_recovery_area/ORA10G/autobackup/2011_07_17/o1_mf_s_756768121_725rhvkf_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/app/oradata/ora10g/control01.ctl
output filename=/u01/app/oradata/ora10g/control02.ctl
output filename=/u01/app/oradata/ora10g/control03.ctl
Finished restore at 2011-07-17-21:28:34

RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1

RMAN> list incarnation;

List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1