增量备份恢复的一个小例子
背景:一个项目需要恢复一个库做测试,之前有源库的增量备份(0+1+2级),时间窗口只有5H,测试的时候发现恢复一个0级全备需要3H,再加一些其他操作,时间窗口内完成测试较为紧张。一个同事提出说在进行2级增量恢复的时候,数据库会从之前所有可用的0级+2级+1级全部从头来一遍,这样就会花费一个0级恢复的时间,理论上增量备份恢复应该是很智能的,没有这么笨,遂有下边的这个小测试,就是事先将0级restore,等到时间窗口时再recover 2级,这样时间就会腾出来。
增量备份恢复测试
顺序 增量级别 数据时间点
1 0 2013/05/21 18:38:54
2 2 2013/05/21 18:45:15
3 1 2013/05/21 18:51:15
4 2 2013/05/21 18:57:55
恢复顺序
1、恢复0级增量备份(restore+recover)
2、恢复第一个2级(即顺序号为2)的控制文件,恢复数据库(recover)
验证的结果:
在进行2级recover的时候,只应用2级的增量备份的文件,不会再次应用之前的0级备份文件。
**************************************************以下为测试过程**************************************************
数据库版本
SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for Linux: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production
建测试数据
SQL> create tablespace yallonking datafile '/u01/app/oracle/oradata/ora10gr2/yallonking01.dbf' size 1m; Tablespace created. SQL> create user yallonking identified by yallonking default tablespace yallonking quota unlimited on yallonking; User created. SQL> grant dba to yallonking 2 ; Grant succeeded. SQL> conn yallonking/yallonking Connected. SQL> create table yallonking (id number,name varchar2(20),my_date date); Table created. SQL> insert into yallonking values (1,'0',sysdate); 1 row created. SQL> commit; Commit complete. SQL> alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss'; Session altered. SQL> select * from yallonking; ID NAME MY_DATE ---------- -------------------- ------------------- 1 0 2013/05/21 18:38:54
进行0级增量备份
[oracle@ora10gr2 ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 21 18:42:31 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: ORA10GR2 (DBID=4093928674) RMAN> run { 2> allocate channel c1 type disk; 3> allocate channel c2 type disk; 4> backup 5> incremental level 0 6> skip inaccessible filesperset 5 7> Database format='/tmp/orcl_lev0_%U_%T' tag='orcl_lev0' ; 8> sql 'alter system archive log current'; 9> backup format '/tmp/arch_%s_%p_%t.bak' 10> filesperset 5 11> archivelog all delete input skip inaccessible; 12> backup current controlfile tag='bak_ctlfile' format='/tmp/ctl_file_%U_%T'; 13> backup spfile tag='spfile' format='/tmp/ORCL_spfile_%U_%T'; 14> release channel c1; 15> release channel c2; 16> } using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=145 devtype=DISK ... ... channel c1: backup set complete, elapsed time: 00:00:01 Finished backup at 21-MAY-13 released channel: c1 released channel: c2 RMAN> exit Recovery Manager complete.
插入2级增量的测试数据
SQL> insert into yallonking values (2,'2',sysdate); 1 row created. SQL> commit; Commit complete. SQL> alter system archive log current; System altered. SQL> / System altered. SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. SQL> alter system archive log current; System altered. SQL> select * from yallonking; ID NAME MY_DATE ---------- -------------------- ------------------- 1 0 2013/05/21 18:38:54 2 2 2013/05/21 18:45:15
进行2级增量备份
[oracle@ora10gr2 ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 21 18:45:44 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: ORA10GR2 (DBID=4093928674) RMAN> run { 2> allocate channel c1 type disk; 3> allocate channel c2 type disk; 4> backup 5> incremental level 2 6> skip inaccessible filesperset 5 7> Database format='/tmp/orcl_lev2_%U_%T' tag='orcl_lev2' ; 8> sql 'alter system archive log current'; 9> backup format '/tmp/arch_%s_%p_%t.bak' 10> filesperset 5 11> archivelog all delete input skip inaccessible; 12> backup current controlfile tag='bak_ctlfile' format='/tmp/ctl_file_%U_%T_level2'; 13> backup spfile tag='spfile' format='/tmp/ORCL_spfile_%U_%T'; 14> release channel c1; 15> release channel c2; 16> } using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=141 devtype=DISK ... ... released channel: c1 released channel: c2 RMAN> exit Recovery Manager complete.
插入1级增量的测试数据
SQL> insert into yallonking values (3,'1',sysdate); 1 row created. SQL> commit; Commit complete. SQL> alter system archive log current; System altered. SQL> / System altered. SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. SQL> alter system archive log current; System altered. SQL> / System altered. SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> select * from yallonking; ID NAME MY_DATE ---------- -------------------- ------------------- 1 0 2013/05/21 18:38:54 2 2 2013/05/21 18:45:15 3 1 2013/05/21 18:51:15
备份1级增量数据库
RMAN> run { 2> allocate channel c1 type disk; 3> allocate channel c2 type disk; 4> backup 5> incremental level 1 6> skip inaccessible filesperset 5 7> Database format='/tmp/orcl_lev1_%U_%T' tag='orcl_lev1' ; 8> sql 'alter system archive log current'; 9> backup format '/tmp/arch_%s_%p_%t.bak' 10> filesperset 5 11> archivelog all delete input skip inaccessible; 12> backup current controlfile tag='bak_ctlfile' format='/tmp/ctl_file_%U_%T_level1'; 13> backup spfile tag='spfile' format='/tmp/ORCL_spfile_%U_%T'; 14> release channel c1; 15> release channel c2; 16> } released channel: ORA_DISK_1 allocated channel: c1 channel c1: sid=148 devtype=DISK ... ... Finished backup at 21-MAY-13 released channel: c1 released channel: c2 RMAN> exit Recovery Manager complete.
再次插入2级增量的测试数据
SQL> insert into yallonking values (4,'2',sysdate); 1 row created. SQL> commit; Commit complete. SQL> alter system archive log current; System altered. SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> / System altered. SQL> alter system archive log current; System altered. SQL> alter system switch logfile; System altered. SQL> / System altered. SQL> alter system archive log current; System altered. SQL> select * from yallonking; ID NAME MY_DATE ---------- -------------------- ------------------- 1 0 2013/05/21 18:38:54 2 2 2013/05/21 18:45:15 3 1 2013/05/21 18:51:15 4 2 2013/05/21 18:57:55
备份2级增量数据库
[oracle@ora10gr2 ~]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 21 19:01:01 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: ORA10GR2 (DBID=4093928674) RMAN> run { 2> allocate channel c1 type disk; 3> allocate channel c2 type disk; 4> backup 5> incremental level 2 6> skip inaccessible filesperset 5 7> Database format='/tmp/orcl_lev2_%U_%T' tag='orcl_lev2' ; 8> sql 'alter system archive log current'; 9> backup format '/tmp/arch_%s_%p_%t.bak' 10> filesperset 5 11> archivelog all delete input skip inaccessible; 12> backup current controlfile tag='bak_ctlfile' format='/tmp/ctl_file_%U_%T_level2'; 13> backup spfile tag='spfile' format='/tmp/ORCL_spfile_%U_%T'; 14> release channel c1; 15> release channel c2; 16> } using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=154 devtype=DISK ... ... Finished backup at 21-MAY-13 released channel: c1 released channel: c2 RMAN> exit Recovery Manager complete.
以下开始恢复测试
删除所有数据文件
SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/ora10gr2/system01.dbf /u01/app/oracle/oradata/ora10gr2/undotbs01.dbf /u01/app/oracle/oradata/ora10gr2/sysaux01.dbf /u01/app/oracle/oradata/ora10gr2/users01.dbf /u01/app/oracle/oradata/ora10gr2/test01.dbf /u01/app/oracle/oradata/ora10gr2/ogg01.dbf /u01/app/oracle/oradata/ora10gr2/yallonking01.dbf 7 rows selected. [oracle@ora10gr2 ~]$ cd /u01/app/oracle/oradata/ora10gr2/ [oracle@ora10gr2 ora10gr2]$ rm -rf *
开始恢复在时间2013/05/21 18:38:54的0级增量备份
再恢复第一个2级备份(即2013/05/21 18:45:15时间点的数据)
[oracle@ora10gr2 ora10gr2]$ ps -ef | grep pmon| grep -v grep oracle 9422 1 0 20:25 ? 00:00:00 ora_pmon_ora10gr2 [oracle@ora10gr2 ora10gr2]$ kill -9 9422 [oracle@ora10gr2 ora10gr2]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 21 20:23:08 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database (not started) RMAN> set DBID=4093928674 executing command: SET DBID RMAN> startup nomount; Oracle instance started Total System Global Area 608174080 bytes Fixed Size 1220844 bytes Variable Size 205524756 bytes Database Buffers 398458880 bytes Redo Buffers 2969600 bytes RMAN> restore controlfile from '/tmp/ctl_file_0coa77bl_1_1_20130521'; --此处是0级的控制文件的备份 Starting restore at 21-MAY-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 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/ora10gr2/control01.ctl output filename=/u01/app/oracle/oradata/ora10gr2/control02.ctl output filename=/u01/app/oracle/oradata/ora10gr2/control03.ctl Finished restore at 21-MAY-13 RMAN> startup mount; database is already started database mounted released channel: ORA_DISK_1 RMAN> restore database; Starting restore at 21-MAY-13 Starting implicit crosscheck backup at 21-MAY-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK Crosschecked 11 objects Finished implicit crosscheck backup at 21-MAY-13 Starting implicit crosscheck copy at 21-MAY-13 using channel ORA_DISK_1 Finished implicit crosscheck copy at 21-MAY-13 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u01/app/oracle/oradata/ora10gr2/system01.dbf restoring datafile 00004 to /u01/app/oracle/oradata/ora10gr2/users01.dbf restoring datafile 00007 to /u01/app/oracle/oradata/ora10gr2/yallonking01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev0_01oa7792_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev0_01oa7792_1_1_20130521 tag=ORCL_LEV0 channel ORA_DISK_1: restore complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00002 to /u01/app/oracle/oradata/ora10gr2/undotbs01.dbf restoring datafile 00003 to /u01/app/oracle/oradata/ora10gr2/sysaux01.dbf restoring datafile 00005 to /u01/app/oracle/oradata/ora10gr2/test01.dbf restoring datafile 00006 to /u01/app/oracle/oradata/ora10gr2/ogg01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev0_02oa7792_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev0_02oa7792_1_1_20130521 tag=ORCL_LEV0 channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 Finished restore at 21-MAY-13 RMAN> recover database; Starting recover at 21-MAY-13 using channel ORA_DISK_1 starting media recovery channel ORA_DISK_1: starting archive log restore to default destination channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=29 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=30 channel ORA_DISK_1: reading from backup piece /tmp/arch_7_1_816029040.bak channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/arch_7_1_816029040.bak tag=TAG20130521T184350 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_29_8srgo72y_.arc thread=1 sequence=29 channel default: deleting archive log(s) archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_29_8srgo72y_.arc recid=60 stamp=816035128 archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_30_8srgo76j_.arc thread=1 sequence=30 channel default: deleting archive log(s) archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_30_8srgo76j_.arc recid=59 stamp=816035127 unable to find archive log archive log thread=1 sequence=31 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 05/21/2013 20:25:32 RMAN-06054: media recovery requesting unknown log: thread 1 seq 31 lowscn 500800 RMAN> shutdown immediate database dismounted Oracle instance shut down RMAN> startup nomount; connected to target database (not started) Oracle instance started Total System Global Area 608174080 bytes Fixed Size 1220844 bytes Variable Size 205524756 bytes Database Buffers 398458880 bytes Redo Buffers 2969600 bytes RMAN> restore controlfile from '/tmp/ctl_file_0toa77kj_1_1_20130521_level2'; --此处是第一个2级增量备份的控制文件 Starting restore at 21-MAY-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 output filename=/u01/app/oracle/oradata/ora10gr2/control01.ctl output filename=/u01/app/oracle/oradata/ora10gr2/control02.ctl output filename=/u01/app/oracle/oradata/ora10gr2/control03.ctl Finished restore at 21-MAY-13 RMAN> startup mount; database is already started database mounted released channel: ORA_DISK_1 RMAN> recover database; Starting recover at 21-MAY-13 Starting implicit crosscheck backup at 21-MAY-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK Crosschecked 28 objects Finished implicit crosscheck backup at 21-MAY-13 Starting implicit crosscheck copy at 21-MAY-13 using channel ORA_DISK_1 Finished implicit crosscheck copy at 21-MAY-13 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00002: /u01/app/oracle/oradata/ora10gr2/undotbs01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/ora10gr2/sysaux01.dbf destination for restore of datafile 00005: /u01/app/oracle/oradata/ora10gr2/test01.dbf destination for restore of datafile 00006: /u01/app/oracle/oradata/ora10gr2/ogg01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev2_0foa77jv_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev2_0foa77jv_1_1_20130521 tag=ORCL_LEV2 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle/oradata/ora10gr2/system01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/ora10gr2/users01.dbf destination for restore of datafile 00007: /u01/app/oracle/oradata/ora10gr2/yallonking01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev2_0eoa77jv_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev2_0eoa77jv_1_1_20130521 tag=ORCL_LEV2 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 starting media recovery channel ORA_DISK_1: starting archive log restore to default destination channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=45 channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=46 channel ORA_DISK_1: reading from backup piece /tmp/arch_28_1_816029328.bak channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/arch_28_1_816029328.bak tag=TAG20130521T184836 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_45_8srh41qv_.arc thread=1 sequence=45 channel default: deleting archive log(s) archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_45_8srh41qv_.arc recid=91 stamp=816035601 archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_46_8srh41rd_.arc thread=1 sequence=46 channel default: deleting archive log(s) archive log filename=/u01/app/oracle/flash_recovery_area/ORA10GR2/archivelog/2013_05_21/o1_mf_1_46_8srh41rd_.arc recid=92 stamp=816035601 unable to find archive log archive log thread=1 sequence=47 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 05/21/2013 20:33:24 RMAN-06054: media recovery requesting unknown log: thread 1 seq 47 lowscn 501062 RMAN> alter database open resetlogs; database opened RMAN> exit Recovery Manager complete.
以上是完整的输出,可以看到在恢复2级的时候只应用了2级的增量备份的备份片。
验证恢复结果
[oracle@ora10gr2 ora10gr2]$ sqlplus "/as sysdba" SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 21 20:34:13 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss'; Session altered. SQL> select * from yallonking.yallonking; ID NAME MY_DATE ---------- -------------------- ------------------- 1 0 2013/05/21 18:38:54 2 2 2013/05/21 18:45:15
*************************下边继续尝试在resetlogs打开库并进行了事物后,能否再继续恢复*************************
正常进行事物
SQL> insert into yallonking.yallonking values(10,'after_resetlogs_open',sysdate); 1 row created. SQL> commit; Commit complete. SQL> alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss'; Session altered. SQL> select * from yallonking.yallonking; ID NAME MY_DATE ---------- -------------------- ------------------- 1 0 2013/05/21 18:38:54 2 2 2013/05/21 18:45:15 10 after_resetlogs_open 2013/05/21 21:49:43
下边继续进行之前的增量的恢复
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. [oracle@ora10gr2 ora10gr2]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 21 21:51:51 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database (not started) RMAN> startup nomount; Oracle instance started Total System Global Area 608174080 bytes Fixed Size 1220844 bytes Variable Size 213913364 bytes Database Buffers 390070272 bytes Redo Buffers 2969600 bytes RMAN> restore controlfile from '/tmp/ctl_file_1soa78bo_1_1_20130521_level2'; --此处是最新的控制及文件的备份 Starting restore at 21-MAY-13 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 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/ora10gr2/control01.ctl output filename=/u01/app/oracle/oradata/ora10gr2/control02.ctl output filename=/u01/app/oracle/oradata/ora10gr2/control03.ctl Finished restore at 21-MAY-13 RMAN> startup mount; database is already started database mounted released channel: ORA_DISK_1 RMAN> recover database; Starting recover at 21-MAY-13 Starting implicit crosscheck backup at 21-MAY-13 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK Crosschecked 59 objects Finished implicit crosscheck backup at 21-MAY-13 Starting implicit crosscheck copy at 21-MAY-13 using channel ORA_DISK_1 Finished implicit crosscheck copy at 21-MAY-13 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 starting media recovery media recovery failed RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 05/21/2013 21:52:39 ORA-00283: recovery session canceled due to errors RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed start until cancel using backup controlfile ORA-00283: recovery session canceled due to errors ORA-19909: datafile 1 belongs to an orphan incarnation ORA-01110: data file 1: '/u01/app/oracle/oradata/ora10gr2/system01.dbf' RMAN> restore database; Starting restore at 21-MAY-13 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u01/app/oracle/oradata/ora10gr2/system01.dbf restoring datafile 00004 to /u01/app/oracle/oradata/ora10gr2/users01.dbf restoring datafile 00007 to /u01/app/oracle/oradata/ora10gr2/yallonking01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev0_01oa7792_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev0_01oa7792_1_1_20130521 tag=ORCL_LEV0 channel ORA_DISK_1: restore complete, elapsed time: 00:00:25 channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00002 to /u01/app/oracle/oradata/ora10gr2/undotbs01.dbf restoring datafile 00003 to /u01/app/oracle/oradata/ora10gr2/sysaux01.dbf restoring datafile 00005 to /u01/app/oracle/oradata/ora10gr2/test01.dbf restoring datafile 00006 to /u01/app/oracle/oradata/ora10gr2/ogg01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev0_02oa7792_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev0_02oa7792_1_1_20130521 tag=ORCL_LEV0 channel ORA_DISK_1: restore complete, elapsed time: 00:00:15 Finished restore at 21-MAY-13 RMAN> recover database; Starting recover at 21-MAY-13 using channel ORA_DISK_1 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle/oradata/ora10gr2/system01.dbf destination for restore of datafile 00007: /u01/app/oracle/oradata/ora10gr2/yallonking01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev1_0voa77v2_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev1_0voa77v2_1_1_20130521 tag=ORCL_LEV1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00002: /u01/app/oracle/oradata/ora10gr2/undotbs01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/ora10gr2/sysaux01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/ora10gr2/users01.dbf destination for restore of datafile 00005: /u01/app/oracle/oradata/ora10gr2/test01.dbf destination for restore of datafile 00006: /u01/app/oracle/oradata/ora10gr2/ogg01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev1_10oa77v3_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev1_10oa77v3_1_1_20130521 tag=ORCL_LEV1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle/oradata/ora10gr2/system01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/ora10gr2/users01.dbf destination for restore of datafile 00007: /u01/app/oracle/oradata/ora10gr2/yallonking01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev1_1boa780s_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev1_1boa780s_1_1_20130521 tag=ORCL_LEV1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00002: /u01/app/oracle/oradata/ora10gr2/undotbs01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/ora10gr2/sysaux01.dbf destination for restore of datafile 00005: /u01/app/oracle/oradata/ora10gr2/test01.dbf destination for restore of datafile 00006: /u01/app/oracle/oradata/ora10gr2/ogg01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev1_1coa780s_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev1_1coa780s_1_1_20130521 tag=ORCL_LEV1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /u01/app/oracle/oradata/ora10gr2/system01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/ora10gr2/users01.dbf destination for restore of datafile 00007: /u01/app/oracle/oradata/ora10gr2/yallonking01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev2_1koa78bf_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev2_1koa78bf_1_1_20130521 tag=ORCL_LEV2 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00002: /u01/app/oracle/oradata/ora10gr2/undotbs01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/ora10gr2/sysaux01.dbf destination for restore of datafile 00005: /u01/app/oracle/oradata/ora10gr2/test01.dbf destination for restore of datafile 00006: /u01/app/oracle/oradata/ora10gr2/ogg01.dbf channel ORA_DISK_1: reading from backup piece /tmp/orcl_lev2_1loa78bf_1_1_20130521 channel ORA_DISK_1: restored backup piece 1 piece handle=/tmp/orcl_lev2_1loa78bf_1_1_20130521 tag=ORCL_LEV2 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 starting media recovery archive log thread 1 sequence 68 is already on disk as file /u01/app/oracle/oradata/arch/1_68_791701862.dbf archive log thread 1 sequence 69 is already on disk as file /u01/app/oracle/oradata/arch/1_69_791701862.dbf archive log filename=/u01/app/oracle/oradata/arch/1_68_791701862.dbf thread=1 sequence=68 archive log filename=/u01/app/oracle/oradata/arch/1_69_791701862.dbf thread=1 sequence=69 unable to find archive log archive log thread=1 sequence=70 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 05/21/2013 21:53:53 RMAN-06054: media recovery requesting unknown log: thread 1 seq 70 lowscn 502078 RMAN> alter database open resetlogs; database opened RMAN> exit Recovery Manager complete. [oracle@ora10gr2 ora10gr2]$ sqlplus "/as sysdba" SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 21 21:54:35 2013 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss'; Session altered. SQL> select * from yallonking.yallonking; ID NAME MY_DATE ---------- -------------------- ------------------- 1 0 2013/05/21 18:38:54 2 2 2013/05/21 18:45:15 3 1 2013/05/21 18:51:15 4 2 2013/05/21 18:57:55
此处发现,在resetlogs打开库并进行事物后,这样的恢复会先恢复0级再恢复后边1级再恢复最近的2级。也说明了,在resetlogs打开库后,之前的备份还是可以用的。