1、前提条件
必须存在删除表空间时间节点以前的全库备份。
2、特点
数据库不必关机。
先克隆一个数据库实例,在克隆数据库上进行表空间单点恢复,再将恢复的表空间传送回源数据库(XTTS)。
3、步骤
3.1、将要恢复的时间节点转换成SCN
select timestamp_to_scn(to_date('2024-04-12:10:49:15','YYYY-MM-DD:HH24:MI:SS')) from dual;
3.2、执行过程
[oracle@classroom ~]$ rman target / Recovery Manager: Release 12.1.0.2.0 - Production on Fri Apr 12 10:58:59 2024 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (DBID=1691043747) RMAN> recover tablespace users until scn 2599477 2> auxiliary destination '/u01/app/oracle/oradata'; Starting recover at 12-APR-24 using target database control file instead of recovery catalog current log archived allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=131 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Oracle Secure Backup allocated channel: ORA_SBT_TAPE_2 channel ORA_SBT_TAPE_2: SID=130 device type=SBT_TAPE channel ORA_SBT_TAPE_2: Oracle Secure Backup allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=254 device type=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: SID=370 device type=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: SID=256 device type=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: SID=13 device type=DISK allocated channel: ORA_DISK_5 channel ORA_DISK_5: SID=371 device type=DISK allocated channel: ORA_DISK_6 channel ORA_DISK_6: SID=16 device type=DISK allocated channel: ORA_DISK_7 channel ORA_DISK_7: SID=135 device type=DISK allocated channel: ORA_DISK_8 channel ORA_DISK_8: SID=257 device type=DISK 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='fFrd' initialization parameters used for automatic instance: db_name=ORCL db_unique_name=fFrd_pitr_ORCL compatible=12.1.0.2.0 db_block_size=8192 db_files=200 diagnostic_dest=/u01/app/oracle _system_trig_enabled=FALSE sga_target=1024M processes=200 db_create_file_dest=/u01/app/oracle/oradata log_archive_dest_1='location=/u01/app/oracle/oradata' #No auxiliary parameter file used starting up automatic instance ORCL Oracle instance started Total System Global Area 1073741824 bytes Fixed Size 2932632 bytes Variable Size 293601384 bytes Database Buffers 771751936 bytes Redo Buffers 5455872 bytes Automatic instance created List of tablespaces that have been dropped from the target database: Tablespace USERS contents of Memory Script: { # set requested point in time set until scn 2599477; # 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 12-APR-24 allocated channel: ORA_AUX_SBT_TAPE_1 channel ORA_AUX_SBT_TAPE_1: SID=88 device type=SBT_TAPE channel ORA_AUX_SBT_TAPE_1: Oracle Secure Backup allocated channel: ORA_AUX_SBT_TAPE_2 channel ORA_AUX_SBT_TAPE_2: SID=169 device type=SBT_TAPE channel ORA_AUX_SBT_TAPE_2: Oracle Secure Backup allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=250 device type=DISK allocated channel: ORA_AUX_DISK_2 channel ORA_AUX_DISK_2: SID=7 device type=DISK allocated channel: ORA_AUX_DISK_3 channel ORA_AUX_DISK_3: SID=89 device type=DISK allocated channel: ORA_AUX_DISK_4 channel ORA_AUX_DISK_4: SID=170 device type=DISK allocated channel: ORA_AUX_DISK_5 channel ORA_AUX_DISK_5: SID=251 device type=DISK allocated channel: ORA_AUX_DISK_6 channel ORA_AUX_DISK_6: SID=8 device type=DISK allocated channel: ORA_AUX_DISK_7 channel ORA_AUX_DISK_7: SID=90 device type=DISK allocated channel: ORA_AUX_DISK_8 channel ORA_AUX_DISK_8: SID=171 device type=DISK channel ORA_AUX_SBT_TAPE_1: starting datafile backup set restore channel ORA_AUX_SBT_TAPE_1: restoring control file channel ORA_AUX_SBT_TAPE_1: reading from backup piece 0c2o2b01_1_1 channel ORA_AUX_SBT_TAPE_1: piece handle=0c2o2b01_1_1 tag=LABS-14-CONTR-BEFORE-DROP channel ORA_AUX_SBT_TAPE_1: restored backup piece 1 channel ORA_AUX_SBT_TAPE_1: restore complete, elapsed time: 00:00:25 output file name=/u01/app/oracle/oradata/ORCL/controlfile/o1_mf_m1k90cjx_.ctl Finished restore at 12-APR-24 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 scn 2599477; # set destinations for recovery set and auxiliary set datafiles set newname for clone datafile 1 to new; set newname for clone datafile 4 to new; set newname for clone datafile 3 to new; set newname for clone tempfile 1 to new; set newname for datafile 6 to new; # switch all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set and the auxiliary set restore clone datafile 1, 4, 3, 6; switch clone datafile all; } executing Memory Script executing command: SET until clause executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME renamed tempfile 1 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 12-APR-24 using channel ORA_AUX_SBT_TAPE_1 using channel ORA_AUX_SBT_TAPE_2 using channel ORA_AUX_DISK_1 using channel ORA_AUX_DISK_2 using channel ORA_AUX_DISK_3 using channel ORA_AUX_DISK_4 using channel ORA_AUX_DISK_5 using channel ORA_AUX_DISK_6 using channel ORA_AUX_DISK_7 using channel ORA_AUX_DISK_8 channel ORA_AUX_DISK_1: restoring datafile 00001 input datafile copy RECID=7 STAMP=1164534743 file name=/u01/app/oracle/oradata/orcl/system01.dbf destination for restore of datafile 00001: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_%u_.dbf channel ORA_AUX_DISK_2: restoring datafile 00004 input datafile copy RECID=9 STAMP=1164534743 file name=/u01/app/oracle/oradata/orcl/undotbs01.dbf destination for restore of datafile 00004: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_%u_.dbf channel ORA_AUX_DISK_3: restoring datafile 00003 input datafile copy RECID=8 STAMP=1164534743 file name=/u01/app/oracle/oradata/orcl/sysaux01.dbf destination for restore of datafile 00003: /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_%u_.dbf channel ORA_AUX_DISK_4: restoring datafile 00006 input datafile copy RECID=11 STAMP=1164534743 file name=/u01/app/oracle/oradata/orcl/users01.dbf destination for restore of datafile 00006: +data channel ORA_AUX_DISK_4: copied datafile copy of datafile 00006 output file name=+DATA/ORCL/DATAFILE/users.263.1166094111 RECID=12 STAMP=1166094114 channel ORA_AUX_DISK_2: copied datafile copy of datafile 00004 output file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_m1k90xn8_.dbf RECID=13 STAMP=1166094177 channel ORA_AUX_DISK_3: copied datafile copy of datafile 00003 output file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_m1k90xnb_.dbf RECID=14 STAMP=1166094237 channel ORA_AUX_DISK_1: copied datafile copy of datafile 00001 output file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_m1k90xn6_.dbf RECID=15 STAMP=1166094239 Finished restore at 12-APR-24 datafile 6 switched to datafile copy input datafile copy RECID=16 STAMP=1166094248 file name=+DATA/ORCL/DATAFILE/users.263.1166094111 datafile 1 switched to datafile copy input datafile copy RECID=17 STAMP=1166094248 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_m1k90xn6_.dbf datafile 4 switched to datafile copy input datafile copy RECID=18 STAMP=1166094248 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_m1k90xn8_.dbf datafile 3 switched to datafile copy input datafile copy RECID=19 STAMP=1166094248 file name=/u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_m1k90xnb_.dbf contents of Memory Script: { # set requested point in time set until scn 2599477; # online the datafiles restored or switched sql clone "alter database datafile 1 online"; sql clone "alter database datafile 4 online"; sql clone "alter database datafile 3 online"; sql clone "alter database datafile 6 online"; # recover and open resetlogs recover clone database tablespace "USERS", "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 4 online sql statement: alter database datafile 3 online sql statement: alter database datafile 6 online Starting recover at 12-APR-24 using channel ORA_AUX_SBT_TAPE_1 using channel ORA_AUX_SBT_TAPE_2 using channel ORA_AUX_DISK_1 using channel ORA_AUX_DISK_2 using channel ORA_AUX_DISK_3 using channel ORA_AUX_DISK_4 using channel ORA_AUX_DISK_5 using channel ORA_AUX_DISK_6 using channel ORA_AUX_DISK_7 using channel ORA_AUX_DISK_8 starting media recovery archived log for thread 1 with sequence 14 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_14.259.1164535185 archived log for thread 1 with sequence 15 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_15.261.1164535251 archived log for thread 1 with sequence 16 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_16.262.1164535257 archived log for thread 1 with sequence 17 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_17.263.1164535481 archived log for thread 1 with sequence 18 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_18.264.1164578503 archived log for thread 1 with sequence 19 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_03_26/thread_1_seq_19.265.1164596421 archived log for thread 1 with sequence 20 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_20.266.1166086589 archived log for thread 1 with sequence 21 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_21.267.1166087245 archived log for thread 1 with sequence 22 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_22.268.1166090857 archived log for thread 1 with sequence 23 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_23.269.1166093331 archived log for thread 1 with sequence 24 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_24.270.1166093331 archived log for thread 1 with sequence 25 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_25.271.1166093333 archived log for thread 1 with sequence 26 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_26.272.1166093335 archived log for thread 1 with sequence 27 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_27.273.1166093335 archived log for thread 1 with sequence 28 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_28.274.1166093339 archived log for thread 1 with sequence 29 is already on disk as file +FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_29.275.1166094049 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_14.259.1164535185 thread=1 sequence=14 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_15.261.1164535251 thread=1 sequence=15 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_16.262.1164535257 thread=1 sequence=16 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_17.263.1164535481 thread=1 sequence=17 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_03_25/thread_1_seq_18.264.1164578503 thread=1 sequence=18 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_03_26/thread_1_seq_19.265.1164596421 thread=1 sequence=19 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_20.266.1166086589 thread=1 sequence=20 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_21.267.1166087245 thread=1 sequence=21 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_22.268.1166090857 thread=1 sequence=22 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_23.269.1166093331 thread=1 sequence=23 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_24.270.1166093331 thread=1 sequence=24 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_25.271.1166093333 thread=1 sequence=25 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_26.272.1166093335 thread=1 sequence=26 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_27.273.1166093335 thread=1 sequence=27 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_28.274.1166093339 thread=1 sequence=28 archived log file name=+FRA/ORCL/ARCHIVELOG/2024_04_12/thread_1_seq_29.275.1166094049 thread=1 sequence=29 media recovery complete, elapsed time: 00:00:20 Finished recover at 12-APR-24 database opened contents of Memory Script: { # make read only the tablespace that will be exported sql clone 'alter tablespace USERS read only'; # create directory for datapump import sql "create or replace directory TSPITR_DIROBJ_DPDIR as '' /u01/app/oracle/oradata''"; # create directory for datapump export sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as '' /u01/app/oracle/oradata''"; } executing Memory Script sql statement: alter tablespace USERS read only sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata'' sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata'' Performing export of metadata... EXPDP> Starting "SYS"."TSPITR_EXP_fFrd_wwyB": EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX EXPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT EXPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS EXPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS EXPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK EXPDP> Master table "SYS"."TSPITR_EXP_fFrd_wwyB" successfully loaded/unloaded EXPDP> ****************************************************************************** EXPDP> Dump file set for SYS.TSPITR_EXP_fFrd_wwyB is: EXPDP> /u01/app/oracle/oradata/tspitr_fFrd_75652.dmp EXPDP> ****************************************************************************** EXPDP> Datafiles required for transportable tablespace USERS: EXPDP> +DATA/ORCL/DATAFILE/users.263.1166094111 EXPDP> Job "SYS"."TSPITR_EXP_fFrd_wwyB" successfully completed at Fri Apr 12 11:05:46 2024 elapsed 0 00:00:51 Export completed contents of Memory Script: { # shutdown clone before import shutdown clone abort } executing Memory Script Oracle instance shut down Performing import of metadata... IMPDP> Master table "SYS"."TSPITR_IMP_fFrd_esty" successfully loaded/unloaded IMPDP> Starting "SYS"."TSPITR_IMP_fFrd_esty": IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE IMPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX IMPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT IMPDP> Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS IMPDP> Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS IMPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK IMPDP> Job "SYS"."TSPITR_IMP_fFrd_esty" successfully completed at Fri Apr 12 11:06:38 2024 elapsed 0 00:00:33 Import completed contents of Memory Script: { # make read write and offline the imported tablespaces sql 'alter tablespace USERS read write'; sql 'alter tablespace USERS offline'; # enable autobackups after TSPITR is finished sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;'; } executing Memory Script sql statement: alter tablespace USERS read write sql statement: alter tablespace USERS offline sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end; Removing automatic instance Automatic instance removed auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_temp_m1k963j5_.tmp deleted auxiliary instance file /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_3_m1k960b2_.log deleted auxiliary instance file /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_2_m1k95y38_.log deleted auxiliary instance file /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_1_m1k95xdn_.log deleted auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_m1k90xnb_.dbf deleted auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_m1k90xn8_.dbf deleted auxiliary instance file /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_m1k90xn6_.dbf deleted auxiliary instance file /u01/app/oracle/oradata/ORCL/controlfile/o1_mf_m1k90cjx_.ctl deleted auxiliary instance file tspitr_fFrd_75652.dmp deleted Finished recover at 12-APR-24 RMAN> alter tablespace users online; Statement processed RMAN>
标签:datafile,单点,thread,恢复,TSPITR,file,DISK,channel,ORA From: https://www.cnblogs.com/aries0228/p/18130803