一、说明

1、参数 log_archive_format 和 log_archive_dest_n 决定了rman恢复时获取归档的路径和名字。 2、使用方法 从归档备份中恢复归档到新的位置 run{ set archivelog destination to '/oracle/test/archivelog/'; restore archivelog from sequence 1; } 调用新位置的归档进行数据库恢复 run { set archivelog destination to '/oracle/test/archivelog/'; restore database; recover database; }

二、例子

1、从备份恢复归档到指定位置 RMAN> run{ 2> set archivelog destination to '/oracle/test/archivelog/'; 3> restore archivelog from sequence 1; 4> }

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 2013-03-21 09:36:47 using channel ORA_DISK_1 using channel ORA_DISK_2

channel ORA_DISK_1: starting archived log restore to user-specified destination archived log destination=/oracle/test/archivelog/ channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=1 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=2 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=3 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=4 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=5 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=6 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=7 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=8 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=9 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=10 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=11 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=12 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=13 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=14 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=15 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=16 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=17 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=18 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=19 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=20 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=21 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=22 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=23 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=24 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=25 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=26 channel ORA_DISK_1: reading from backup piece /backup/20130320_l4o50vf8_1_1 channel ORA_DISK_2: starting archived log restore to user-specified destination archived log destination=/oracle/test/archivelog/ channel ORA_DISK_2: restoring archived log archived log thread=1 sequence=27 channel ORA_DISK_2: restoring archived log archived log thread=1 sequence=28 channel ORA_DISK_2: restoring archived log archived log thread=1 sequence=29 channel ORA_DISK_2: restoring archived log archived log thread=1 sequence=30 channel ORA_DISK_2: restoring archived log archived log thread=1 sequence=31 channel ORA_DISK_2: reading from backup piece /backup/20130320_l5o50vfa_1_1 channel ORA_DISK_2: piece handle=/backup/20130320_l5o50vfa_1_1 tag=TAG20130320T173111 channel ORA_DISK_2: restored backup piece 1 channel ORA_DISK_2: restore complete, elapsed time: 00:00:02 channel ORA_DISK_1: piece handle=/backup/20130320_l4o50vf8_1_1 tag=TAG20130320T173111 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:04 Finished restore at 2013-03-21 09:36:51

2、调用指定位置的归档进行recover操作 RMAN> run 2> { 3> set archivelog destination to '/oracle/test/archivelog/'; 4> restore database; 5> recover database; 6> }

executing command: SET ARCHIVELOG DESTINATION using target database control file instead of recovery catalog

Starting restore at 2013-03-21 09:40:37 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=129 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=192 device type=DISK

skipping datafile 5; already restored to file /oracle/CRM/pos1.dbf skipping datafile 9; already restored to file /oracle/CRM/pos2.dbf channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00003 to /oracle/CRM/test/UNDOTBS33.dbf channel ORA_DISK_1: restoring datafile 00004 to /oracle/CRM/test/USERS4.dbf channel ORA_DISK_1: restoring datafile 00006 to /oracle/CRM/test/ERP6.dbf channel ORA_DISK_1: restoring datafile 00008 to /oracle/CRM/test/TEST8.dbf channel ORA_DISK_1: reading from backup piece /backup/20130320_kpo50uom_1_1 channel ORA_DISK_2: starting datafile backup set restore channel ORA_DISK_2: specifying datafile(s) to restore from backup set channel ORA_DISK_2: restoring datafile 00001 to /oracle/CRM/test/SYSTEM1.dbf channel ORA_DISK_2: restoring datafile 00002 to /oracle/CRM/test/SYSAUX2.dbf channel ORA_DISK_2: restoring datafile 00007 to /oracle/CRM/test/USER017.dbf channel ORA_DISK_2: reading from backup piece /backup/20130320_kqo50uon_1_1 channel ORA_DISK_2: piece handle=/backup/20130320_kqo50uon_1_1 tag=TAG20130320T171916 channel ORA_DISK_2: restored backup piece 1 channel ORA_DISK_2: restore complete, elapsed time: 00:03:16 channel ORA_DISK_1: piece handle=/backup/20130320_kpo50uom_1_1 tag=TAG20130320T171916 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:03:26 Finished restore at 2013-03-21 09:44:04

Starting recover at 2013-03-21 09:44:06 using channel ORA_DISK_1 using channel ORA_DISK_2 datafile 5 not processed because file is read-only datafile 9 not processed because file is read-only

starting media recovery

archived log for thread 1 with sequence 9 is already on disk as file /oracle/test/archivelog/1_9_810495590.dbf archived log for thread 1 with sequence 10 is already on disk as file /oracle/test/archivelog/1_10_810495590.dbf archived log for thread 1 with sequence 11 is already on disk as file /oracle/test/archivelog/1_11_810495590.dbf archived log for thread 1 with sequence 12 is already on disk as file /oracle/test/archivelog/1_12_810495590.dbf archived log for thread 1 with sequence 13 is already on disk as file /oracle/test/archivelog/1_13_810495590.dbf archived log for thread 1 with sequence 14 is already on disk as file /oracle/test/archivelog/1_14_810495590.dbf archived log for thread 1 with sequence 15 is already on disk as file /oracle/test/archivelog/1_15_810495590.dbf archived log for thread 1 with sequence 16 is already on disk as file /oracle/test/archivelog/1_16_810495590.dbf archived log for thread 1 with sequence 17 is already on disk as file /oracle/test/archivelog/1_17_810495590.dbf archived log for thread 1 with sequence 18 is already on disk as file /oracle/test/archivelog/1_18_810495590.dbf archived log for thread 1 with sequence 19 is already on disk as file /oracle/test/archivelog/1_19_810495590.dbf archived log for thread 1 with sequence 20 is already on disk as file /oracle/test/archivelog/1_20_810495590.dbf archived log for thread 1 with sequence 21 is already on disk as file /oracle/test/archivelog/1_21_810495590.dbf archived log for thread 1 with sequence 22 is already on disk as file /oracle/test/archivelog/1_22_810495590.dbf archived log for thread 1 with sequence 23 is already on disk as file /oracle/test/archivelog/1_23_810495590.dbf archived log for thread 1 with sequence 24 is already on disk as file /oracle/test/archivelog/1_24_810495590.dbf archived log for thread 1 with sequence 25 is already on disk as file /oracle/test/archivelog/1_25_810495590.dbf archived log for thread 1 with sequence 26 is already on disk as file /oracle/test/archivelog/1_26_810495590.dbf archived log for thread 1 with sequence 27 is already on disk as file /oracle/test/archivelog/1_27_810495590.dbf archived log for thread 1 with sequence 28 is already on disk as file /oracle/test/archivelog/1_28_810495590.dbf archived log for thread 1 with sequence 29 is already on disk as file /oracle/test/archivelog/1_29_810495590.dbf archived log for thread 1 with sequence 30 is already on disk as file /oracle/test/archivelog/1_30_810495590.dbf archived log for thread 1 with sequence 31 is already on disk as file /oracle/test/archivelog/1_31_810495590.dbf archived log file name=/oracle/test/archivelog/1_9_810495590.dbf thread=1 sequence=9 archived log file name=/oracle/test/archivelog/1_10_810495590.dbf thread=1 sequence=10 archived log file name=/oracle/test/archivelog/1_11_810495590.dbf thread=1 sequence=11 archived log file name=/oracle/test/archivelog/1_12_810495590.dbf thread=1 sequence=12 archived log file name=/oracle/test/archivelog/1_13_810495590.dbf thread=1 sequence=13 archived log file name=/oracle/test/archivelog/1_14_810495590.dbf thread=1 sequence=14 archived log file name=/oracle/test/archivelog/1_15_810495590.dbf thread=1 sequence=15 archived log file name=/oracle/test/archivelog/1_16_810495590.dbf thread=1 sequence=16 archived log file name=/oracle/test/archivelog/1_17_810495590.dbf thread=1 sequence=17 archived log file name=/oracle/test/archivelog/1_18_810495590.dbf thread=1 sequence=18 archived log file name=/oracle/test/archivelog/1_19_810495590.dbf thread=1 sequence=19 archived log file name=/oracle/test/archivelog/1_20_810495590.dbf thread=1 sequence=20 archived log file name=/oracle/test/archivelog/1_21_810495590.dbf thread=1 sequence=21 archived log file name=/oracle/test/archivelog/1_22_810495590.dbf thread=1 sequence=22 archived log file name=/oracle/test/archivelog/1_23_810495590.dbf thread=1 sequence=23 archived log file name=/oracle/test/archivelog/1_24_810495590.dbf thread=1 sequence=24 archived log file name=/oracle/test/archivelog/1_25_810495590.dbf thread=1 sequence=25 archived log file name=/oracle/test/archivelog/1_26_810495590.dbf thread=1 sequence=26 archived log file name=/oracle/test/archivelog/1_27_810495590.dbf thread=1 sequence=27 archived log file name=/oracle/test/archivelog/1_28_810495590.dbf thread=1 sequence=28 media recovery complete, elapsed time: 00:00:11 Finished recover at 2013-03-21 09:44:23