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 3325522;
plsql <<<--
declare
sqlstatement varchar2(512);
pdbname varchar2(30);
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
pdbname := null; -- pdbname
sqlstatement := 'alter tablespace '|| 'tbs_test' ||' offline immediate';
krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement, 0, pdbname);
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 4 to new;
set newname for clone datafile 3 to new;
set newname for clone tempfile 1 to new;
set newname for datafile 2 to
"/u01/app/oracle/oradata/sztech/SZTECH/datafile/tbs_test01.dbf";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 2;
contents of Memory Script:
{
# set requested point in time
set until scn 3325522;
# 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 2 online";
# recover and open resetlogs
recover clone database tablespace "tbs_test", "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 2 online
Starting recover at 31-JUL-20
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file /u01/app/oracle/fast_recovery_area/SZTECH/archivelog/2020_07_31/o1_mf_1_8_hl6z8gn2_.arc
archived log for thread 1 with sequence 9 is already on disk as file /u01/app/oracle/fast_recovery_area/SZTECH/archivelog/2020_07_31/o1_mf_1_9_hl6z9kvv_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/SZTECH/archivelog/2020_07_31/o1_mf_1_8_hl6z8gn2_.arc thread=1 sequence=8
archived log file name=/u01/app/oracle/fast_recovery_area/SZTECH/archivelog/2020_07_31/o1_mf_1_9_hl6z9kvv_.arc thread=1 sequence=9
media recovery complete, elapsed time: 00:00:00
Finished recover at 31-JUL-20
database opened
contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace tbs_test read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/home/oracle''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/home/oracle''";
}
executing Memory Script
sql statement: alter tablespace tbs_test read only
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/home/oracle''
Performing export of metadata...
EXPDP> Starting "SYS"."TSPITR_EXP_mulf_fAvi":
EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
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_mulf_fAvi" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_mulf_fAvi is:
EXPDP> /home/oracle/tspitr_mulf_24306.dmp
EXPDP> ******************************************************************************
EXPDP> Datafiles required for transportable tablespace tbs_test:
EXPDP> /u01/app/oracle/oradata/sztech/SZTECH/datafile/tbs_test01.dbf
EXPDP> Job "SYS"."TSPITR_EXP_mulf_fAvi" successfully completed at Fri Jul 31 10:14:33 2020 elapsed 0 00:00:49
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
# drop target tablespaces before importing them back
sql 'drop tablespace tbs_test including contents keep datafiles cascade constraints';
}
executing Memory Script
Oracle instance shut down
sql statement: drop tablespace tbs_test including contents keep datafiles cascade constraints
Performing import of metadata...
IMPDP> Master table "SYS"."TSPITR_IMP_mulf_cmrk" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_mulf_cmrk":
IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
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_mulf_cmrk" successfully completed at Fri Jul 31 10:14:51 2020 elapsed 0 00:00:12
Import completed
contents of Memory Script:
{
# make read write and offline the imported tablespaces
sql 'alter tablespace tbs_test read write';
sql 'alter tablespace tbs_test offline';
# enable autobackups after TSPITR is finished
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script
sql statement: alter tablespace tbs_test read write
sql statement: alter tablespace tbs_test offline
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
附:
RMAN 执行表空间恢复的步骤:
1. Creates the auxiliary instance, starts it, and connects to it
2. Takes the tablespaces that will be recovered offline
3. Restores a backup control file from a point in time before the target time to the auxiliary instance
4. Restores the data files from the recovery set and the auxiliary set to the auxiliary instance
5. Recovers the restored data files to the specified time
6. Opens the auxiliary database with the RESETLOGS option
7. Exports the dictionary metadata about objects in the recovered tablespaces to the target database
8. Shuts down the auxiliary instance. (Issues SWITCH commands on the target database so that the target database control file points to the data files in the recovery set that were recovered on the auxiliary instance)
9. Imports the dictionary metadata from the auxiliary instance to the target instance
10. Deletes all auxiliary set files