RMAN> recover tablespace tbs_tspitr1,tbs_tspitr2 until time "to_date( '2019-08-26 13:50:38', 'yyyy-mm-dd hh24:mi:ss')" auxiliary destination '/tmp/aux'; Starting recover at 26-AUG-19 using channel ORA_DISK_1 RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point-in-time List of tablespaces expected to have UNDO segments Tablespace SYSTEM Tablespace UNDOTBS1 Creating automatic instance, with SID='qBcb' initialization parameters used for automatic instance: db_name=OCM1 db_unique_name=qBcb_tspitr_OCM1 compatible=11.2.0.0.0 db_block_size=8192 db_files=200 sga_target=280M processes=50 db_create_file_dest=/tmp/aux log_archive_dest_1='location=/tmp/aux' #No auxiliary parameter file used starting up automatic instance OCM1 Oracle instance started Total System Global Area 292278272 bytes Fixed Size 2212736 bytes Variable Size 100666496 bytes Database Buffers 184549376 bytes Redo Buffers 4849664 bytes Automatic instance created Running TRANSPORT_SET_CHECK on recovery set tablespaces TRANSPORT_SET_CHECK completed successfully contents of Memory Script: { # set requested point in time set until time "to_date( '2019-08-26 13:50:38', 'yyyy-mm-dd hh24:mi:ss')"; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log sql 'alter system archive log current'; # avoid unnecessary autobackups for structural changes during TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;'; } executing Memory Script executing command: SET until clause Starting restore at 26-AUG-19 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=17 device type=DISK channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /oracle/app/oracle/flash_recovery_area/OCM1/autobackup/2019_08_26/o1_mf_s_1017323428_gp6ws4qq_.bkp channel ORA_AUX_DISK_1: piece handle=/oracle/app/oracle/flash_recovery_area/OCM1/autobackup/2019_08_26/o1_mf_s_1017323428_gp6ws4qq_.bkp tag=TAG20190826T135028 --这里是从flash_recovery_area中读取的备份数据,在测试此项目时,若关闭flash_recovery_area时,会报取不到备份的问题,后来又打开此功能才不报错,这里需要特殊注意下。 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 output file name=/tmp/aux/OCM1/controlfile/o1_mf_gp6x7ckg_.ctl Finished restore at 26-AUG-19 sql statement: alter database mount clone database sql statement: alter system archive log current sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; contents of Memory Script: { # set requested point in time set until time "to_date( '2019-08-26 13:50:38', 'yyyy-mm-dd hh24:mi:ss')"; plsql <<<-- tspitr_2 declare sqlstatement varchar2(512); offline_not_needed exception; pragma exception_init(offline_not_needed, -01539); begin sqlstatement := 'alter tablespace '|| 'TBS_TSPITR1' ||' offline immediate'; krmicd.writeMsg(6162, sqlstatement); krmicd.execSql(sqlstatement); exception when offline_not_needed then null; end; >>>; plsql <<<-- tspitr_2 declare sqlstatement varchar2(512); offline_not_needed exception; pragma exception_init(offline_not_needed, -01539); begin sqlstatement := 'alter tablespace '|| 'TBS_TSPITR2' ||' offline immediate'; krmicd.writeMsg(6162, sqlstatement); krmicd.execSql(sqlstatement); exception when offline_not_needed then null; end; >>>; # set destinations for recovery set and auxiliary set datafiles set newname for clone datafile 1 to new; set newname for clone datafile 3 to new; set newname for clone datafile 2 to new; set newname for clone tempfile 1 to new; set newname for datafile 5 to "/oracle/app/oracle/oradata/tbs_tspitr1.dbf"; set newname for datafile 6 to "/oracle/app/oracle/oradata/tbs_tspitr2.dbf"; # switch all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 1, 3, 2, 5, 6; switch clone datafile all; } executing Memory Script executing command: SET until clause sql statement: alter tablespace TBS_TSPITR1 offline immediate sql statement: alter tablespace TBS_TSPITR2 offline immediate executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME renamed tempfile 1 to /tmp/aux/OCM1/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 26-AUG-19 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00001 to /tmp/aux/OCM1/datafile/o1_mf_system_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/aux/OCM1/datafile/o1_mf_undotbs1_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00002 to /tmp/aux/OCM1/datafile/o1_mf_sysaux_%u_.dbf channel ORA_AUX_DISK_1: restoring datafile 00005 to /oracle/app/oracle/oradata/tbs_tspitr1.dbf channel ORA_AUX_DISK_1: restoring datafile 00006 to /oracle/app/oracle/oradata/tbs_tspitr2.dbf channel ORA_AUX_DISK_1: reading from backup piece /tmp/tempbak/db_OCM1_full_02ua67rv_1_1 channel ORA_AUX_DISK_1: piece handle=/tmp/tempbak/db_OCM1_full_02ua67rv_1_1 tag=TAG20190826T134951 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35 Finished restore at 26-AUG-19 datafile 1 switched to datafile copy input datafile copy RECID=4 STAMP=1017323925 file name=/tmp/aux/OCM1/datafile/o1_mf_system_gp6x7krl_.dbf datafile 3 switched to datafile copy input datafile copy RECID=5 STAMP=1017323925 file name=/tmp/aux/OCM1/datafile/o1_mf_undotbs1_gp6x7ks5_.dbf datafile 2 switched to datafile copy input datafile copy RECID=6 STAMP=1017323925 file name=/tmp/aux/OCM1/datafile/o1_mf_sysaux_gp6x7ks2_.dbf contents of Memory Script: { # set requested point in time set until time "to_date( '2019-08-26 13:50:38', 'yyyy-mm-dd hh24:mi:ss')"; # online the datafiles restored or switched sql clone "alter database datafile 1 online"; sql clone "alter database datafile 3 online"; sql clone "alter database datafile 2 online"; sql clone "alter database datafile 5 online"; sql clone "alter database datafile 6 online"; # recover and open resetlogs recover clone database tablespace "TBS_TSPITR1", "TBS_TSPITR2", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog; alter clone database open resetlogs; } executing Memory Script executing command: SET until clause sql statement: alter database datafile 1 online sql statement: alter database datafile 3 online sql statement: alter database datafile 2 online sql statement: alter database datafile 5 online sql statement: alter database datafile 6 online Starting recover at 26-AUG-19 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 50 is already on disk as file /oracle/app/oracle/flash_recovery_area/OCM1/archivelog/2019_08_26/o1_mf_1_50_gp6ws2pg_.arc archived log for thread 1 with sequence 51 is already on disk as file /oracle/app/oracle/flash_recovery_area/OCM1/archivelog/2019_08_26/o1_mf_1_51_gp6x7jz7_.arc archived log file name=/oracle/app/oracle/flash_recovery_area/OCM1/archivelog/2019_08_26/o1_mf_1_50_gp6ws2pg_.arc thread=1 sequence=50 archived log file name=/oracle/app/oracle/flash_recovery_area/OCM1/archivelog/2019_08_26/o1_mf_1_51_gp6x7jz7_.arc thread=1 sequence=51 media recovery complete, elapsed time: 00:00:01 Finished recover at 26-AUG-19 database opened contents of Memory Script: { # make read only the tablespace that will be exported sql clone 'alter tablespace TBS_TSPITR1 read only'; sql clone 'alter tablespace TBS_TSPITR2 read only'; # create directory for datapump import sql "create or replace directory TSPITR_DIROBJ_DPDIR as '' /tmp/aux''"; # create directory for datapump export sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as '' /tmp/aux''"; } executing Memory Script sql statement: alter tablespace TBS_TSPITR1 read only sql statement: alter tablespace TBS_TSPITR2 read only sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp/aux'' sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/tmp/aux'' Performing export of metadata... EXPDP> Starting "SYS"."TSPITR_EXP_qBcb": EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX EXPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK EXPDP> Master table "SYS"."TSPITR_EXP_qBcb" successfully loaded/unloaded EXPDP> ****************************************************************************** EXPDP> Dump file set for SYS.TSPITR_EXP_qBcb is: EXPDP> /tmp/aux/tspitr_qBcb_14246.dmp EXPDP> ****************************************************************************** EXPDP> Datafiles required for transportable tablespace TBS_TSPITR1: EXPDP> /oracle/app/oracle/oradata/tbs_tspitr1.dbf EXPDP> Datafiles required for transportable tablespace TBS_TSPITR2: EXPDP> /oracle/app/oracle/oradata/tbs_tspitr2.dbf EXPDP> Job "SYS"."TSPITR_EXP_qBcb" successfully completed at 13:59:27 Export completed contents of Memory Script: { # shutdown clone before import shutdown clone immediate # drop target tablespaces before importing them back sql 'drop tablespace TBS_TSPITR1 including contents keep datafiles'; sql 'drop tablespace TBS_TSPITR2 including contents keep datafiles'; } executing Memory Script database closed database dismounted Oracle instance shut down sql statement: drop tablespace TBS_TSPITR1 including contents keep datafiles sql statement: drop tablespace TBS_TSPITR2 including contents keep datafiles Performing import of metadata... IMPDP> Master table "SYS"."TSPITR_IMP_qBcb" successfully loaded/unloaded IMPDP> Starting "SYS"."TSPITR_IMP_qBcb": IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE IMPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX IMPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT IMPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK IMPDP> Job "SYS"."TSPITR_IMP_qBcb" successfully completed at 13:59:45 Import completed contents of Memory Script: { # make read write and offline the imported tablespaces sql 'alter tablespace TBS_TSPITR1 read write'; sql 'alter tablespace TBS_TSPITR1 offline'; sql 'alter tablespace TBS_TSPITR2 read write'; sql 'alter tablespace TBS_TSPITR2 offline'; # enable autobackups after TSPITR is finished sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;'; } executing Memory Script sql statement: alter tablespace TBS_TSPITR1 read write sql statement: alter tablespace TBS_TSPITR1 offline sql statement: alter tablespace TBS_TSPITR2 read write sql statement: alter tablespace TBS_TSPITR2 offline sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end; Removing automatic instance Automatic instance removed auxiliary instance file /tmp/aux/OCM1/datafile/o1_mf_temp_gp6x8w38_.tmp deleted auxiliary instance file /tmp/aux/OCM1/onlinelog/o1_mf_3_gp6x8smg_.log deleted auxiliary instance file /tmp/aux/OCM1/onlinelog/o1_mf_2_gp6x8r2j_.log deleted auxiliary instance file /tmp/aux/OCM1/onlinelog/o1_mf_1_gp6x8pfr_.log deleted auxiliary instance file /tmp/aux/OCM1/datafile/o1_mf_sysaux_gp6x7ks2_.dbf deleted auxiliary instance file /tmp/aux/OCM1/datafile/o1_mf_undotbs1_gp6x7ks5_.dbf deleted auxiliary instance file /tmp/aux/OCM1/datafile/o1_mf_system_gp6x7krl_.dbf deleted auxiliary instance file /tmp/aux/OCM1/controlfile/o1_mf_gp6x7ckg_.ctl deleted Finished recover at 26-AUG-19 RMAN> 参考于:https://blog.csdn.net/leshami/article/details/70670220