RMAN使用備份傳輸表空間的各種自定義操作
執行傳輸表空間時指定Data Pump檔案目錄
可以修改傳輸表空間集的Data Pump匯出的dump檔名,示例指令碼名和日誌檔名。預設情況下這些檔案
儲存在表空間目錄中且預設名稱如下:
.Data Pump匯出的dump檔名為dmpfile.dmp
.匯出日誌檔案explog.log
.示例指令碼impscrpt.sql
可以透過指定datapump directory子句來指定dump檔案和匯出日誌檔案的儲存目錄,datapumpdirectory子句使用的是資料庫目錄物件名,不是檔案系統目錄的目錄路徑。
下面的例子將使用指定datapump directory,dump file,export log和import script檔名的transport tablespace命令來執行表空間傳輸。
1.確認源資料庫與目標資料庫所在平臺是不是傳輸表空間所支援的作業系統平臺。
確認源資料庫作業系統平臺:
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d 2 where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT ----------------------------------------------------------------------------------------------------- -------------- Linux IA (32-bit) Little
確認目資料庫作業系統平臺:
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d 2 where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT ----------------------------------------------------------------------------------------------------- -------------- Linux IA (32-bit) Little
這裡作業系統平臺都是Linux
2.確認要被傳輸的表空間是否是自包含表空間(TSPITR,TEST):
SQL> exec sys.dbms_tts.transport_set_check('TSPITR',true); PL/SQL procedure successfully completed. SQL> exec sys.dbms_tts.transport_set_check('TEST',true); PL/SQL procedure successfully completed. SQL> select * from sys.transport_set_violations; no rows selected
如果沒有行選擇,表示該表空間只包含表資料,可以傳輸。
SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 0 SQL> select count(*) from test.test; COUNT(*) ---------- 50683
3.對源資料庫執行備份,在執行備份時一定要加上include current controlfile否則執行transport tablespace命令時會出現以下錯誤資訊:
Automatic instance removed RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of tranport tablespace command at 03/26/2015 20:24:22 RMAN-03015: error occurred in stored script Memory Script RMAN-06026: some targets not found - aborting restore RMAN-06024: no backup or copy of the control file found to restore
[oracle@oracle11g admin]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' [oracle@oracle11g admin]$ rman target sys/zzh_2046@test catalog rman/rman@jy Recovery Manager: Release 10.2.0.5.0 - Production on Thu Mar 26 20:01:33 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: TEST (DBID=2168949517) connected to recovery catalog database RMAN> backup as backupset database include current controlfile plus archivelog; Starting backup at 2015-03-26 20:32:19 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=68 recid=75 stamp=875286167 input archive log thread=1 sequence=69 recid=76 stamp=875291999 input archive log thread=1 sequence=70 recid=77 stamp=875302397 input archive log thread=1 sequence=71 recid=78 stamp=875308491 input archive log thread=1 sequence=72 recid=79 stamp=875350203 input archive log thread=1 sequence=73 recid=80 stamp=875351397 input archive log thread=1 sequence=74 recid=81 stamp=875390545 input archive log thread=1 sequence=75 recid=82 stamp=875390643 input archive log thread=1 sequence=76 recid=83 stamp=875391627 input archive log thread=1 sequence=77 recid=84 stamp=875391661 input archive log thread=1 sequence=78 recid=85 stamp=875391764 input archive log thread=1 sequence=79 recid=86 stamp=875392340 channel ORA_DISK_1: starting piece 1 at 2015-03-26 20:32:22 channel ORA_DISK_1: finished piece 1 at 2015-03-26 20:32:29 piece handle=/u02/ora_test875392341_991 tag=TAG20150326T203220 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08 Finished backup at 2015-03-26 20:32:29 Starting backup at 2015-03-26 20:32:29 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset input datafile fno=00001 name=/u01/app/oracle/oradata/test/system01.dbf input datafile fno=00003 name=/u01/app/oracle/oradata/test/sysaux01.dbf input datafile fno=00005 name=/u01/app/oracle/oradata/test/example01.dbf input datafile fno=00006 name=/u01/app/oracle/oradata/test/tspitr01.dbf input datafile fno=00002 name=/u01/app/oracle/oradata/test/undotbs01.dbf input datafile fno=00004 name=/u01/app/oracle/oradata/test/users01.dbf input datafile fno=00007 name=/u01/app/oracle/oradata/test/test01.dbf channel ORA_DISK_1: starting piece 1 at 2015-03-26 20:32:30 channel ORA_DISK_1: finished piece 1 at 2015-03-26 20:33:45 piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset including current control file in backupset channel ORA_DISK_1: starting piece 1 at 2015-03-26 20:33:46 channel ORA_DISK_1: finished piece 1 at 2015-03-26 20:33:47 piece handle=/u02/ora_test875392425_1011 tag=TAG20150326T203229 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 2015-03-26 20:33:47 Starting backup at 2015-03-26 20:33:47 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archive log backupset channel ORA_DISK_1: specifying archive log(s) in backup set input archive log thread=1 sequence=80 recid=87 stamp=875392427 channel ORA_DISK_1: starting piece 1 at 2015-03-26 20:33:49 channel ORA_DISK_1: finished piece 1 at 2015-03-26 20:33:50 piece handle=/u02/ora_test875392428_1021 tag=TAG20150326T203348 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 2015-03-26 20:33:50 Starting Control File and SPFILE Autobackup at 2015-03-26 20:33:50 piece handle=/u02/c-2168949517-20150326-07 comment=NONE Finished Control File and SPFILE Autobackup at 2015-03-26 20:33:54 RMAN> list backup; List of Backup Sets =================== BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ ------------------- 6565 56.14M DISK 00:00:07 2015-03-26 20:32:28 BP Key: 6566 Status: AVAILABLE Compressed: NO Tag: TAG20150326T203220 Piece Name: /u02/ora_test875392341_991 List of Archived Logs in backup set 6565 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- ------------------- ---------- --------- 1 68 1040304 2015-03-25 09:33:41 1064641 2015-03-25 15:02:45 1 69 1064641 2015-03-25 15:02:45 1067420 2015-03-25 16:39:58 1 70 1067420 2015-03-25 16:39:58 1090668 2015-03-25 19:33:17 1 71 1090668 2015-03-25 19:33:17 1093434 2015-03-25 21:14:51 1 72 1093434 2015-03-25 21:14:51 1125870 2015-03-26 08:50:00 1 73 1125870 2015-03-26 08:50:00 1126817 2015-03-26 09:09:56 1 74 1126817 2015-03-26 09:09:56 1144051 2015-03-26 20:02:21 1 75 1144051 2015-03-26 20:02:21 1144106 2015-03-26 20:04:02 1 76 1144106 2015-03-26 20:04:02 1144862 2015-03-26 20:20:27 1 77 1144862 2015-03-26 20:20:27 1144893 2015-03-26 20:21:00 1 78 1144893 2015-03-26 20:21:00 1144980 2015-03-26 20:22:44 1 79 1144980 2015-03-26 20:22:44 1145259 2015-03-26 20:32:19 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 6607 Full 640.39M DISK 00:01:08 2015-03-26 20:33:38 BP Key: 6621 Status: AVAILABLE Compressed: NO Tag: TAG20150326T203229 Piece Name: /u02/ora_test875392350_1001 List of Datafiles in backup set 6607 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- ------------------- ---- 1 Full 1145279 2015-03-26 20:32:30 /u01/app/oracle/oradata/test/system01.dbf 2 Full 1145279 2015-03-26 20:32:30 /u01/app/oracle/oradata/test/undotbs01.dbf 3 Full 1145279 2015-03-26 20:32:30 /u01/app/oracle/oradata/test/sysaux01.dbf 4 Full 1145279 2015-03-26 20:32:30 /u01/app/oracle/oradata/test/users01.dbf 5 Full 1145279 2015-03-26 20:32:30 /u01/app/oracle/oradata/test/example01.dbf 6 Full 1145279 2015-03-26 20:32:30 /u01/app/oracle/oradata/test/tspitr01.dbf 7 Full 1145279 2015-03-26 20:32:30 /u01/app/oracle/oradata/test/test01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 6608 Full 7.02M DISK 00:00:01 2015-03-26 20:33:46 BP Key: 6622 Status: AVAILABLE Compressed: NO Tag: TAG20150326T203229 Piece Name: /u02/ora_test875392425_1011 Control File Included: Ckp SCN: 1145304 Ckp time: 2015-03-26 20:33:45 BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ ------------------- 6658 2.50K DISK 00:00:01 2015-03-26 20:33:49 BP Key: 6660 Status: AVAILABLE Compressed: NO Tag: TAG20150326T203348 Piece Name: /u02/ora_test875392428_1021 List of Archived Logs in backup set 6658 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- ------------------- ---------- --------- 1 80 1145259 2015-03-26 20:32:19 1145307 2015-03-26 20:33:47 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ ------------------- 6689 Full 7.05M DISK 00:00:01 2015-03-26 20:33:52 BP Key: 6691 Status: AVAILABLE Compressed: NO Tag: TAG20150326T203351 Piece Name: /u02/c-2168949517-20150326-07 Control File Included: Ckp SCN: 1145329 Ckp time: 2015-03-26 20:33:51 SPFILE Included: Modification time: 2015-03-26 19:31:13
4.建立一個資料庫目錄物件用來執行Data Pump匯出
SQL> create or replace directory test_dump as '/u02/dump_test'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded.
RMAN> transport tablespace "TSPITR","TEST" tablespace destination '/u02/transport' auxiliary destination '/u02/transport' 2> 3> 4> datapump directory test_dump 5> dump file 'test.dmp' 6> import script 'importtest.sql' 7> export log 'testexport.log'; Creating automatic instance, with SID='meiB' initialization parameters used for automatic instance: db_name=TEST compatible=10.2.0.5.0 db_block_size=8192 db_files=200 db_unique_name=tspitr_TEST_meiB sga_target=180M processes=50 #No auxiliary parameter file used db_create_file_dest=/u02/transport control_files=/u02/transport/cntrl_tspitr_TEST_meiB.f starting up automatic instance TEST Oracle instance started Total System Global Area 188743680 bytes Fixed Size 1272720 bytes Variable Size 62915696 bytes Database Buffers 121634816 bytes Redo Buffers 2920448 bytes Automatic instance created contents of Memory Script: { # set the until clause set until scn 1202258; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log for tspitr to a resent until time sql 'alter system archive log current'; # avoid unnecessary autobackups for structural changes during TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;'; # resync catalog after controlfile restore resync catalog; } executing Memory Script executing command: SET until clause Starting restore at 28-MAR-15 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: sid=47 devtype=DISK channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /u02/c-2168949517-20150326-07 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/c-2168949517-20150326-07 tag=TAG20150326T203351 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02 output filename=/u02/transport/cntrl_tspitr_TEST_meiB.f Finished restore at 28-MAR-15 sql statement: alter database mount clone database sql statement: alter system archive log current sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; starting full resync of recovery catalog full resync complete contents of Memory Script: { # generated tablespace point-in-time recovery script # set the until clause set until scn 1202258; # set an omf destination filename for restore set newname for clone datafile 1 to new; # set an omf destination filename for restore set newname for clone datafile 2 to new; # set an omf destination filename for restore set newname for clone datafile 3 to new; # set an omf destination tempfile set newname for clone tempfile 1 to new; # set a destination filename for restore set newname for datafile 6 to "/u02/transport/tspitr01.dbf"; # set a destination filename for restore set newname for datafile 7 to "/u02/transport/test01.dbf"; # rename all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set plus the auxilliary tablespaces restore clone datafile 1, 2, 3, 6, 7; switch clone datafile all; #online the datafiles restored or flipped sql clone "alter database datafile 1 online"; #online the datafiles restored or flipped sql clone "alter database datafile 2 online"; #online the datafiles restored or flipped sql clone "alter database datafile 3 online"; #online the datafiles restored or flipped sql clone "alter database datafile 6 online"; #online the datafiles restored or flipped sql clone "alter database datafile 7 online"; # make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TSPITR", "TEST", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog; alter clone database open resetlogs; # PLUG HERE the creation of a temporary tablespace if export fails due to lack # of temporary space. # For example in Unix these two lines would do that: #sql clone "create tablespace aux_tspitr_tmp # datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K"; } 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 executing command: SET NEWNAME renamed temporary file 1 to /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 28-MAR-15 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_system_%u_.dbf restoring datafile 00002 to /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_undotbs1_%u_.dbf restoring datafile 00003 to /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_sysaux_%u_.dbf restoring datafile 00006 to /u02/transport/tspitr01.dbf restoring datafile 00007 to /u02/transport/test01.dbf channel ORA_AUX_DISK_1: reading from backup piece /u02/ora_test875392350_1001 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:45 Finished restore at 28-MAR-15 datafile 1 switched to datafile copy input datafile copy recid=22 stamp=875560079 filename=/u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_system_bkf2s69f_.dbf datafile 2 switched to datafile copy input datafile copy recid=23 stamp=875560079 filename=/u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_undotbs1_bkf2s6b2_.dbf datafile 3 switched to datafile copy input datafile copy recid=24 stamp=875560079 filename=/u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_sysaux_bkf2s69q_.dbf datafile 6 switched to datafile copy input datafile copy recid=25 stamp=875560079 filename=/u02/transport/tspitr01.dbf datafile 7 switched to datafile copy input datafile copy recid=26 stamp=875560079 filename=/u02/transport/test01.dbf sql statement: alter database datafile 1 online sql statement: alter database datafile 2 online sql statement: alter database datafile 3 online sql statement: alter database datafile 6 online sql statement: alter database datafile 7 online Starting recover at 28-MAR-15 using channel ORA_AUX_DISK_1 starting media recovery archive log thread 1 sequence 80 is already on disk as file /u02/1_80_870806981.dbf archive log thread 1 sequence 81 is already on disk as file /u02/1_81_870806981.dbf archive log thread 1 sequence 82 is already on disk as file /u02/1_82_870806981.dbf archive log thread 1 sequence 83 is already on disk as file /u02/1_83_870806981.dbf archive log thread 1 sequence 84 is already on disk as file /u02/1_84_870806981.dbf archive log thread 1 sequence 85 is already on disk as file /u02/1_85_870806981.dbf archive log thread 1 sequence 86 is already on disk as file /u02/1_86_870806981.dbf archive log thread 1 sequence 87 is already on disk as file /u02/1_87_870806981.dbf archive log filename=/u02/1_80_870806981.dbf thread=1 sequence=80 archive log filename=/u02/1_81_870806981.dbf thread=1 sequence=81 archive log filename=/u02/1_82_870806981.dbf thread=1 sequence=82 archive log filename=/u02/1_83_870806981.dbf thread=1 sequence=83 archive log filename=/u02/1_84_870806981.dbf thread=1 sequence=84 archive log filename=/u02/1_85_870806981.dbf thread=1 sequence=85 archive log filename=/u02/1_86_870806981.dbf thread=1 sequence=86 archive log filename=/u02/1_87_870806981.dbf thread=1 sequence=87 media recovery complete, elapsed time: 00:00:43 Finished recover at 28-MAR-15 database opened contents of Memory Script: { #mark read only the tablespace that will be exported sql clone "alter tablespace TSPITR read only"; #mark read only the tablespace that will be exported sql clone "alter tablespace TEST read only"; # export the tablespaces in the recovery set host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle\)\(ARGV0=oraclemeiB\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=meiB^'\)\)\(CONNECT_DATA=\(SID=meiB\)\)\) as sysdba\" transport_tablespaces= TSPITR, TEST dumpfile= test.dmp directory= test_dump logfile= testexport.log'; } executing Memory Script sql statement: alter tablespace TSPITR read only sql statement: alter tablespace TEST read only Export: Release 10.2.0.5.0 - Production on Saturday, 28 March, 2015 19:09:17 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle)(ARGV0=oraclemeiB)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=meiB))(CONNECT_DATA=(SID=meiB))) AS SYSDBA" transport_tablespaces= TSPITR, TEST dumpfile=test.dmp directory=test_dump logfile=testexport.log Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is: /u02/dump_test/test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 19:10:21 host command complete /* The following command may be used to import the tablespaces. Substitute values for and . impdp directory= dumpfile= 'test.dmp' transport_datafiles= /u02/transport/tspitr01.dbf, /u02/transport/test01.dbf */ -------------------------------------------------------------- -- Start of sample PL/SQL script for importing the tablespaces -------------------------------------------------------------- -- creating directory objects CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u02/transport/'; /* PL/SQL Script to import the exported tablespaces */ DECLARE -- the datafiles tbs_files dbms_streams_tablespace_adm.file_set; cvt_files dbms_streams_tablespace_adm.file_set; -- the dumpfile to import dump_file dbms_streams_tablespace_adm.file; dp_job_name VARCHAR2(30) := NULL; -- names of tablespaces that were imported ts_names dbms_streams_tablespace_adm.tablespace_set; BEGIN -- dump file name and location dump_file.file_name := 'test.dmp'; dump_file.directory_object := 'test_dump'; -- forming list of datafiles for import tbs_files( 1).file_name := 'tspitr01.dbf'; tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1'; tbs_files( 2).file_name := 'test01.dbf'; tbs_files( 2).directory_object := 'STREAMS$DIROBJ$1'; -- import tablespaces dbms_streams_tablespace_adm.attach_tablespaces( datapump_job_name => dp_job_name, dump_file => dump_file, tablespace_files => tbs_files, converted_files => cvt_files, tablespace_names => ts_names); -- output names of imported tablespaces IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN FOR i IN ts_names.first .. ts_names.last LOOP dbms_output.put_line('imported tablespace '|| ts_names(i)); END LOOP; END IF; END; / -- dropping directory objects DROP DIRECTORY STREAMS$DIROBJ$1; -------------------------------------------------------------- -- End of sample PL/SQL script -------------------------------------------------------------- Removing automatic instance shutting down automatic instance Oracle instance shut down Automatic instance removed auxiliary instance file /u02/transport/cntrl_tspitr_TEST_meiB.f deleted auxiliary instance file /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_system_bkf2s69f_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_undotbs1_bkf2s6b2_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_sysaux_bkf2s69q_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_MEIB/datafile/o1_mf_temp_bkf2ydmv_.tmp deleted auxiliary instance file /u02/transport/TSPITR_TEST_MEIB/onlinelog/o1_mf_1_bkf2xxxc_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_MEIB/onlinelog/o1_mf_2_bkf2xzww_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_MEIB/onlinelog/o1_mf_3_bkf2y2qn_.log deleted
[oracle@oracle11g transport]$ ls -lrt total 112784 drwxr-x--- 4 oracle oinstall 4096 Mar 28 19:06 TSPITR_TEST_MEIB -rw-r----- 1 oracle oinstall 104865792 Mar 28 19:09 tspitr01.dbf -rw-r----- 1 oracle oinstall 10493952 Mar 28 19:09 test01.dbf -rw-r--r-- 1 oracle oinstall 2065 Mar 28 19:10 importtest.sql [oracle@oracle11g dump_test]$ ls -lrt total 104 -rw-r--r-- 1 oracle oinstall 1242 Mar 28 19:10 testexport.log -rw-r----- 1 oracle oinstall 98304 Mar 28 19:10 test.dmp
從上面的結果可以看到data pump匯出檔案為test.dmp,匯出日誌檔案為testexport.log,示例匯入指令碼為importtest.sql,與指定的名稱一樣。
5.將步驟4生成的傳輸表空間的資料檔案tspitr01.dbf,test01.dbf和Data Pump匯出檔案dmpfile複製到目標主機上的/u02目錄中
[oracle@jingyong1 u02]$ scp -r oracle@192.168.56.2:/u02/transport/tspitr01.dbf /u02 oracle@192.168.56.2's password: tspitr01.dbf 100% 100MB 7.1MB/s 00:14 [oracle@jingyong1 u02]$ scp -r oracle@192.168.56.2:/u02/transport/test01.dbf /u02 oracle@192.168.56.2's password: test01.dbf 100% 10MB 10.0MB/s 00:00 [oracle@jingyong1 u02]$ scp -r oracle@192.168.56.2:/u02/dump_test/dmpfile.dmp /u02 oracle@192.168.56.2's password: dmpfile.dmp 100% 96KB 96.0KB/s 00:00 [oracle@jingyong1 u02]$ ls -lrt total 112876 -rw-r----- 1 oracle oinstall 104865792 Mar 27 17:54 tspitr01.dbf -rw-r----- 1 oracle oinstall 10493952 Mar 27 18:22 test01.dbf -rw-r----- 1 oracle oinstall 98304 Mar 27 18:22 dmpfile.dmp
6.在目錄主機上建立相關使用者及Data Pump目錄並將表空間附加到目標資料庫中
SQL> create user tspitr identified by "tspitr"; User created. SQL> grant dba,connect,resource to tspitr; Grant succeeded. SQL> create user test identified by "test"; User created. SQL> grant dba,connect,resource to test; Grant succeeded. SQL> create directory mytest as '/u02'; Directory created. SQL> grant read,write on directory mytest to public; Grant succeeded.
最後就可以執行匯入過程了
[oracle@jingyong1 ~]$ export ORACLE_SID=jy [oracle@jingyong1 ~]$ export NLS_DATE_FORMATE='yyyy-mm-dd hh24:mi:ss' [oracle@jingyong1 ~]$ impdp test/test directory=mytest dumpfile=dmpfile.dmp logfile=testtransport.log transport_datafiles= /u02/tspitr01.dbf, /u02/test01.dbf Import: Release 10.2.0.5.0 - Production on Friday, 27 March, 2015 20:28:39 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "TEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "TEST"."SYS_IMPORT_TRANSPORTABLE_01": test/******** directory=mytest dumpfile=dmpfile.dmp logfile=testtransport.log transport_datafiles= /u02/tspitr01.dbf, /u02/test01.dbf Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "TEST"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 20:28:55
進入資料庫中檢查一下
SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 0 SQL> select count(*) from test.test; COUNT(*) ---------- 50683
與表空間傳輸之前的狀態一致
使用自定義引數執行表空間傳輸
對於所有的transport tablespace命令來說,RMAN都會使用預設引數來建立輔助例項。transport tablespace命令也可以使用輔助引數檔案來建立輔助例項,而不是使用預設引數來建立。使用輔助例項引數檔案有以下三個原因:
.為了管理輔助例項資料檔案目錄(例如,不想讓所有的輔助例項資料檔案儲存在相同磁碟目錄中,但不想為每個單獨的資料檔案指定目錄)
.為了使用log_file_name_convert來控制聯機重做日誌的檔名
.為了Data Pump匯出增大shared_pool_size的大小
RMAN傳輸表空間的預設輔助例項引數
對於自動地輔助例項RMAN定義了以下基本引數:
.db_name,與源資料庫的db_name相同
.compatible,與源資料庫的設定相同
.db_unique_name,基於db_name來建立,且唯一
.db_files,與源資料庫的db_files相同
.shared_pool_size,國灰Data Pump Export可能要求更多的空間設定為110M
.large_pool_size,設定為1M
如果使用auxiliary destination引數,RMAN也會定義:
.db_create_file_dest,設定輔助目錄
.control_files,在輔助目錄中生成控制檔案
建立一個引數檔案/u02/initaux.ora,並設定以下引數
[oracle@oracle11g u02]$ vi initaux.ora shared_pool_size=150M
RMAN> run 2> { 3> set auxiliary instance parameter file to '/u02/initaux.ora'; 4> transport tablespace "TSPITR","TEST" 5> tablespace destination '/u02/transport' 6> auxiliary destination '/u02/transport' ; 7> } executing command: SET auxiliary parameter file Creating automatic instance, with SID='ndyc' using contents of file /u02/initaux.ora initialization parameters used for automatic instance: db_name=TEST compatible=10.2.0.5.0 db_block_size=8192 db_files=200 db_unique_name=tspitr_TEST_ndyc sga_target=180M processes=50 ifile=/u02/initaux.ora db_create_file_dest=/u02/transport control_files=/u02/transport/cntrl_tspitr_TEST_ndyc.f starting up automatic instance TEST Oracle instance started Total System Global Area 188743680 bytes Fixed Size 1272720 bytes Variable Size 167773296 bytes Database Buffers 16777216 bytes Redo Buffers 2920448 bytes Automatic instance created contents of Memory Script: { # set the until clause set until scn 1202636; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log for tspitr to a resent until time sql 'alter system archive log current'; # avoid unnecessary autobackups for structural changes during TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;'; # resync catalog after controlfile restore resync catalog; } executing Memory Script executing command: SET until clause Starting restore at 28-MAR-15 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: sid=47 devtype=DISK channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /u02/c-2168949517-20150326-07 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/c-2168949517-20150326-07 tag=TAG20150326T203351 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:09 output filename=/u02/transport/cntrl_tspitr_TEST_ndyc.f Finished restore at 28-MAR-15 sql statement: alter database mount clone database sql statement: alter system archive log current sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; starting full resync of recovery catalog full resync complete contents of Memory Script: { # generated tablespace point-in-time recovery script # set the until clause set until scn 1202636; # set an omf destination filename for restore set newname for clone datafile 1 to new; # set an omf destination filename for restore set newname for clone datafile 2 to new; # set an omf destination filename for restore set newname for clone datafile 3 to new; # set an omf destination tempfile set newname for clone tempfile 1 to new; # set a destination filename for restore set newname for datafile 6 to "/u02/transport/tspitr01.dbf"; # set a destination filename for restore set newname for datafile 7 to "/u02/transport/test01.dbf"; # rename all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set plus the auxilliary tablespaces restore clone datafile 1, 2, 3, 6, 7; switch clone datafile all; #online the datafiles restored or flipped sql clone "alter database datafile 1 online"; #online the datafiles restored or flipped sql clone "alter database datafile 2 online"; #online the datafiles restored or flipped sql clone "alter database datafile 3 online"; #online the datafiles restored or flipped sql clone "alter database datafile 6 online"; #online the datafiles restored or flipped sql clone "alter database datafile 7 online"; # make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TSPITR", "TEST", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog; alter clone database open resetlogs; # PLUG HERE the creation of a temporary tablespace if export fails due to lack # of temporary space. # For example in Unix these two lines would do that: #sql clone "create tablespace aux_tspitr_tmp # datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K"; } 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 executing command: SET NEWNAME renamed temporary file 1 to /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 28-MAR-15 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_system_%u_.dbf restoring datafile 00002 to /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_undotbs1_%u_.dbf restoring datafile 00003 to /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_sysaux_%u_.dbf restoring datafile 00006 to /u02/transport/tspitr01.dbf restoring datafile 00007 to /u02/transport/test01.dbf channel ORA_AUX_DISK_1: reading from backup piece /u02/ora_test875392350_1001 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:25 Finished restore at 28-MAR-15 datafile 1 switched to datafile copy input datafile copy recid=22 stamp=875563331 filename=/u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_system_bkf5zggf_.dbf datafile 2 switched to datafile copy input datafile copy recid=23 stamp=875563331 filename=/u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_undotbs1_bkf5zgjg_.dbf datafile 3 switched to datafile copy input datafile copy recid=24 stamp=875563331 filename=/u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_sysaux_bkf5zggr_.dbf datafile 6 switched to datafile copy input datafile copy recid=25 stamp=875563331 filename=/u02/transport/tspitr01.dbf datafile 7 switched to datafile copy input datafile copy recid=26 stamp=875563331 filename=/u02/transport/test01.dbf sql statement: alter database datafile 1 online sql statement: alter database datafile 2 online sql statement: alter database datafile 3 online sql statement: alter database datafile 6 online sql statement: alter database datafile 7 online Starting recover at 28-MAR-15 using channel ORA_AUX_DISK_1 starting media recovery archive log thread 1 sequence 80 is already on disk as file /u02/1_80_870806981.dbf archive log thread 1 sequence 81 is already on disk as file /u02/1_81_870806981.dbf archive log thread 1 sequence 82 is already on disk as file /u02/1_82_870806981.dbf archive log thread 1 sequence 83 is already on disk as file /u02/1_83_870806981.dbf archive log thread 1 sequence 84 is already on disk as file /u02/1_84_870806981.dbf archive log thread 1 sequence 85 is already on disk as file /u02/1_85_870806981.dbf archive log thread 1 sequence 86 is already on disk as file /u02/1_86_870806981.dbf archive log thread 1 sequence 87 is already on disk as file /u02/1_87_870806981.dbf archive log thread 1 sequence 88 is already on disk as file /u02/1_88_870806981.dbf archive log filename=/u02/1_80_870806981.dbf thread=1 sequence=80 archive log filename=/u02/1_81_870806981.dbf thread=1 sequence=81 archive log filename=/u02/1_82_870806981.dbf thread=1 sequence=82 archive log filename=/u02/1_83_870806981.dbf thread=1 sequence=83 archive log filename=/u02/1_84_870806981.dbf thread=1 sequence=84 archive log filename=/u02/1_85_870806981.dbf thread=1 sequence=85 archive log filename=/u02/1_86_870806981.dbf thread=1 sequence=86 archive log filename=/u02/1_87_870806981.dbf thread=1 sequence=87 archive log filename=/u02/1_88_870806981.dbf thread=1 sequence=88 media recovery complete, elapsed time: 00:00:55 Finished recover at 28-MAR-15 database opened contents of Memory Script: { #mark read only the tablespace that will be exported sql clone "alter tablespace TSPITR read only"; #mark read only the tablespace that will be exported sql clone "alter tablespace TEST read only"; # create directory for datapump export sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as '' /u02/transport''"; # export the tablespaces in the recovery set host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle\)\(ARGV0=oraclendyc\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=ndyc^'\)\)\(CONNECT_DATA=\(SID=ndyc\)\)\) as sysdba\" transport_tablespaces= TSPITR, TEST dumpfile= dmpfile.dmp directory= STREAMS_DIROBJ_DPDIR logfile= explog.log'; } executing Memory Script sql statement: alter tablespace TSPITR read only sql statement: alter tablespace TEST read only sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u02/transport'' Export: Release 10.2.0.5.0 - Production on Saturday, 28 March, 2015 20:03:36 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle)(ARGV0=oraclendyc)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=ndyc))(CONNECT_DATA=(SID=ndyc))) AS SYSDBA" transport_tablespaces= TSPITR, TEST dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is: /u02/transport/dmpfile.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:04:38 host command complete /* The following command may be used to import the tablespaces. Substitute values for and . impdp directory= dumpfile= 'dmpfile.dmp' transport_datafiles= /u02/transport/tspitr01.dbf, /u02/transport/test01.dbf */ -------------------------------------------------------------- -- Start of sample PL/SQL script for importing the tablespaces -------------------------------------------------------------- -- creating directory objects CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u02/transport/'; CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u02/transport'; /* PL/SQL Script to import the exported tablespaces */ DECLARE -- the datafiles tbs_files dbms_streams_tablespace_adm.file_set; cvt_files dbms_streams_tablespace_adm.file_set; -- the dumpfile to import dump_file dbms_streams_tablespace_adm.file; dp_job_name VARCHAR2(30) := NULL; -- names of tablespaces that were imported ts_names dbms_streams_tablespace_adm.tablespace_set; BEGIN -- dump file name and location dump_file.file_name := 'dmpfile.dmp'; dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR'; -- forming list of datafiles for import tbs_files( 1).file_name := 'tspitr01.dbf'; tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1'; tbs_files( 2).file_name := 'test01.dbf'; tbs_files( 2).directory_object := 'STREAMS$DIROBJ$1'; -- import tablespaces dbms_streams_tablespace_adm.attach_tablespaces( datapump_job_name => dp_job_name, dump_file => dump_file, tablespace_files => tbs_files, converted_files => cvt_files, tablespace_names => ts_names); -- output names of imported tablespaces IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN FOR i IN ts_names.first .. ts_names.last LOOP dbms_output.put_line('imported tablespace '|| ts_names(i)); END LOOP; END IF; END; / -- dropping directory objects DROP DIRECTORY STREAMS$DIROBJ$1; DROP DIRECTORY STREAMS$DIROBJ$DPDIR; -------------------------------------------------------------- -- End of sample PL/SQL script -------------------------------------------------------------- Removing automatic instance shutting down automatic instance Oracle instance shut down Automatic instance removed auxiliary instance file /u02/transport/cntrl_tspitr_TEST_ndyc.f deleted auxiliary instance file /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_system_bkf5zggf_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_undotbs1_bkf5zgjg_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_sysaux_bkf5zggr_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_NDYC/datafile/o1_mf_temp_bkf6487l_.tmp deleted auxiliary instance file /u02/transport/TSPITR_TEST_NDYC/onlinelog/o1_mf_1_bkf63x6t_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_NDYC/onlinelog/o1_mf_2_bkf63z8n_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_NDYC/onlinelog/o1_mf_3_bkf641h8_.log deleted
使用自定義輔助控制檔案來執行表空間傳輸
[oracle@oracle11g u02]$ vi initaux.ora shared_pool_size=150M control_files=('/u02/transport/control01.ctl')
RMAN> run 2> { 3> set auxiliary instance parameter file to '/u02/initaux.ora'; 4> transport tablespace "TSPITR","TEST" 5> tablespace destination '/u02/transport' 6> auxiliary destination '/u02/transport' ; 7> } executing command: SET auxiliary parameter file Creating automatic instance, with SID='EmBb' using contents of file /u02/initaux.ora initialization parameters used for automatic instance: db_name=TEST compatible=10.2.0.5.0 db_block_size=8192 db_files=200 db_unique_name=tspitr_TEST_EmBb sga_target=180M processes=50 ifile=/u02/initaux.ora db_create_file_dest=/u02/transport control_files=/u02/transport/cntrl_tspitr_TEST_EmBb.f starting up automatic instance TEST Oracle instance started Total System Global Area 188743680 bytes Fixed Size 1272720 bytes Variable Size 167773296 bytes Database Buffers 16777216 bytes Redo Buffers 2920448 bytes Automatic instance created contents of Memory Script: { # set the until clause set until scn 1204101; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log for tspitr to a resent until time sql 'alter system archive log current'; # avoid unnecessary autobackups for structural changes during TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;'; # resync catalog after controlfile restore resync catalog; } executing Memory Script executing command: SET until clause Starting restore at 28-MAR-15 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: sid=47 devtype=DISK channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /u02/c-2168949517-20150326-07 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/c-2168949517-20150326-07 tag=TAG20150326T203351 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 output filename=/u02/transport/cntrl_tspitr_TEST_EmBb.f Finished restore at 28-MAR-15 sql statement: alter database mount clone database sql statement: alter system archive log current sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; starting full resync of recovery catalog full resync complete contents of Memory Script: { # generated tablespace point-in-time recovery script # set the until clause set until scn 1204101; # set an omf destination filename for restore set newname for clone datafile 1 to new; # set an omf destination filename for restore set newname for clone datafile 2 to new; # set an omf destination filename for restore set newname for clone datafile 3 to new; # set an omf destination tempfile set newname for clone tempfile 1 to new; # set a destination filename for restore set newname for datafile 6 to "/u02/transport/tspitr01.dbf"; # set a destination filename for restore set newname for datafile 7 to "/u02/transport/test01.dbf"; # rename all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set plus the auxilliary tablespaces restore clone datafile 1, 2, 3, 6, 7; switch clone datafile all; #online the datafiles restored or flipped sql clone "alter database datafile 1 online"; #online the datafiles restored or flipped sql clone "alter database datafile 2 online"; #online the datafiles restored or flipped sql clone "alter database datafile 3 online"; #online the datafiles restored or flipped sql clone "alter database datafile 6 online"; #online the datafiles restored or flipped sql clone "alter database datafile 7 online"; # make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TSPITR", "TEST", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog; alter clone database open resetlogs; # PLUG HERE the creation of a temporary tablespace if export fails due to lack # of temporary space. # For example in Unix these two lines would do that: #sql clone "create tablespace aux_tspitr_tmp # datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K"; } 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 executing command: SET NEWNAME renamed temporary file 1 to /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 28-MAR-15 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_system_%u_.dbf restoring datafile 00002 to /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_undotbs1_%u_.dbf restoring datafile 00003 to /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_sysaux_%u_.dbf restoring datafile 00006 to /u02/transport/tspitr01.dbf restoring datafile 00007 to /u02/transport/test01.dbf channel ORA_AUX_DISK_1: reading from backup piece /u02/ora_test875392350_1001 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:35 Finished restore at 28-MAR-15 datafile 1 switched to datafile copy input datafile copy recid=22 stamp=875563883 filename=/u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_system_bkf6jddz_.dbf datafile 2 switched to datafile copy input datafile copy recid=23 stamp=875563883 filename=/u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_undotbs1_bkf6jdmt_.dbf datafile 3 switched to datafile copy input datafile copy recid=24 stamp=875563883 filename=/u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_sysaux_bkf6jdfc_.dbf datafile 6 switched to datafile copy input datafile copy recid=25 stamp=875563883 filename=/u02/transport/tspitr01.dbf datafile 7 switched to datafile copy input datafile copy recid=26 stamp=875563883 filename=/u02/transport/test01.dbf sql statement: alter database datafile 1 online sql statement: alter database datafile 2 online sql statement: alter database datafile 3 online sql statement: alter database datafile 6 online sql statement: alter database datafile 7 online Starting recover at 28-MAR-15 using channel ORA_AUX_DISK_1 starting media recovery archive log thread 1 sequence 80 is already on disk as file /u02/1_80_870806981.dbf archive log thread 1 sequence 81 is already on disk as file /u02/1_81_870806981.dbf archive log thread 1 sequence 82 is already on disk as file /u02/1_82_870806981.dbf archive log thread 1 sequence 83 is already on disk as file /u02/1_83_870806981.dbf archive log thread 1 sequence 84 is already on disk as file /u02/1_84_870806981.dbf archive log thread 1 sequence 85 is already on disk as file /u02/1_85_870806981.dbf archive log thread 1 sequence 86 is already on disk as file /u02/1_86_870806981.dbf archive log thread 1 sequence 87 is already on disk as file /u02/1_87_870806981.dbf archive log thread 1 sequence 88 is already on disk as file /u02/1_88_870806981.dbf archive log thread 1 sequence 89 is already on disk as file /u02/1_89_870806981.dbf archive log filename=/u02/1_80_870806981.dbf thread=1 sequence=80 archive log filename=/u02/1_81_870806981.dbf thread=1 sequence=81 archive log filename=/u02/1_82_870806981.dbf thread=1 sequence=82 archive log filename=/u02/1_83_870806981.dbf thread=1 sequence=83 archive log filename=/u02/1_84_870806981.dbf thread=1 sequence=84 archive log filename=/u02/1_85_870806981.dbf thread=1 sequence=85 archive log filename=/u02/1_86_870806981.dbf thread=1 sequence=86 archive log filename=/u02/1_87_870806981.dbf thread=1 sequence=87 archive log filename=/u02/1_88_870806981.dbf thread=1 sequence=88 archive log filename=/u02/1_89_870806981.dbf thread=1 sequence=89 media recovery complete, elapsed time: 00:00:57 Finished recover at 28-MAR-15 database opened contents of Memory Script: { #mark read only the tablespace that will be exported sql clone "alter tablespace TSPITR read only"; #mark read only the tablespace that will be exported sql clone "alter tablespace TEST read only"; # create directory for datapump export sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as '' /u02/transport''"; # export the tablespaces in the recovery set host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle\)\(ARGV0=oracleEmBb\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=EmBb^'\)\)\(CONNECT_DATA=\(SID=EmBb\)\)\) as sysdba\" transport_tablespaces= TSPITR, TEST dumpfile= dmpfile.dmp directory= STREAMS_DIROBJ_DPDIR logfile= explog.log'; } executing Memory Script sql statement: alter tablespace TSPITR read only sql statement: alter tablespace TEST read only sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u02/transport'' Export: Release 10.2.0.5.0 - Production on Saturday, 28 March, 2015 20:13:04 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle)(ARGV0=oracleEmBb)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=EmBb))(CONNECT_DATA=(SID=EmBb))) AS SYSDBA" transport_tablespaces= TSPITR, TEST dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is: /u02/transport/dmpfile.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:14:05 host command complete /* The following command may be used to import the tablespaces. Substitute values for and . impdp directory= dumpfile= 'dmpfile.dmp' transport_datafiles= /u02/transport/tspitr01.dbf, /u02/transport/test01.dbf */ -------------------------------------------------------------- -- Start of sample PL/SQL script for importing the tablespaces -------------------------------------------------------------- -- creating directory objects CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u02/transport/'; CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u02/transport'; /* PL/SQL Script to import the exported tablespaces */ DECLARE -- the datafiles tbs_files dbms_streams_tablespace_adm.file_set; cvt_files dbms_streams_tablespace_adm.file_set; -- the dumpfile to import dump_file dbms_streams_tablespace_adm.file; dp_job_name VARCHAR2(30) := NULL; -- names of tablespaces that were imported ts_names dbms_streams_tablespace_adm.tablespace_set; BEGIN -- dump file name and location dump_file.file_name := 'dmpfile.dmp'; dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR'; -- forming list of datafiles for import tbs_files( 1).file_name := 'tspitr01.dbf'; tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1'; tbs_files( 2).file_name := 'test01.dbf'; tbs_files( 2).directory_object := 'STREAMS$DIROBJ$1'; -- import tablespaces dbms_streams_tablespace_adm.attach_tablespaces( datapump_job_name => dp_job_name, dump_file => dump_file, tablespace_files => tbs_files, converted_files => cvt_files, tablespace_names => ts_names); -- output names of imported tablespaces IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN FOR i IN ts_names.first .. ts_names.last LOOP dbms_output.put_line('imported tablespace '|| ts_names(i)); END LOOP; END IF; END; / -- dropping directory objects DROP DIRECTORY STREAMS$DIROBJ$1; DROP DIRECTORY STREAMS$DIROBJ$DPDIR; -------------------------------------------------------------- -- End of sample PL/SQL script -------------------------------------------------------------- Removing automatic instance shutting down automatic instance Oracle instance shut down Automatic instance removed auxiliary instance file /u02/transport/cntrl_tspitr_TEST_EmBb.f deleted auxiliary instance file /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_system_bkf6jddz_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_undotbs1_bkf6jdmt_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_sysaux_bkf6jdfc_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_EMBB/datafile/o1_mf_temp_bkf6owoz_.tmp deleted auxiliary instance file /u02/transport/TSPITR_TEST_EMBB/onlinelog/o1_mf_1_bkf6o7p5_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_EMBB/onlinelog/o1_mf_2_bkf6ochy_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_EMBB/onlinelog/o1_mf_3_bkf6ogqc_.log deleted
執行表空間傳輸時為輔助資料檔案設定新檔名(set newname)
可以在RUN塊中使用set newname命令來為transport tablespace命令指定檔案:
RMAN> run 2> { 3> set newname for datafile '/u01/app/oracle/oradata/test/tspitr01.dbf' to '/u02/transport/tspitr01.dbf'; 4> 5> set newname for datafile '/u01/app/oracle/oradata/test/test01.dbf' 6> to '/u02/transport/test01.dbf'; 7> transport tablespace "TSPITR","TEST" 8> tablespace destination '/u02/transport' 9> auxiliary destination '/u02/transport' ; 10> } executing command: SET NEWNAME executing command: SET NEWNAME Creating automatic instance, with SID='Fmly' using contents of file /u02/initaux.ora initialization parameters used for automatic instance: db_name=TEST compatible=10.2.0.5.0 db_block_size=8192 db_files=200 db_unique_name=tspitr_TEST_Fmly sga_target=180M processes=50 ifile=/u02/initaux.ora db_create_file_dest=/u02/transport control_files=/u02/transport/cntrl_tspitr_TEST_Fmly.f starting up automatic instance TEST Oracle instance started Total System Global Area 188743680 bytes Fixed Size 1272720 bytes Variable Size 167773296 bytes Database Buffers 16777216 bytes Redo Buffers 2920448 bytes Automatic instance created contents of Memory Script: { # set the until clause set until scn 1204365; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log for tspitr to a resent until time sql 'alter system archive log current'; # avoid unnecessary autobackups for structural changes during TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;'; # resync catalog after controlfile restore resync catalog; } executing Memory Script executing command: SET until clause Starting restore at 28-MAR-15 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: sid=47 devtype=DISK channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /u02/c-2168949517-20150326-07 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/c-2168949517-20150326-07 tag=TAG20150326T203351 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 output filename=/u02/transport/cntrl_tspitr_TEST_Fmly.f Finished restore at 28-MAR-15 sql statement: alter database mount clone database sql statement: alter system archive log current sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; starting full resync of recovery catalog full resync complete contents of Memory Script: { # generated tablespace point-in-time recovery script # set the until clause set until scn 1204365; # set an omf destination filename for restore set newname for clone datafile 1 to new; # set an omf destination filename for restore set newname for clone datafile 2 to new; # set an omf destination filename for restore set newname for clone datafile 3 to new; # set an omf destination tempfile set newname for clone tempfile 1 to new; # set a destination filename for restore set newname for datafile 6 to "/u02/transport/tspitr01.dbf"; # set a destination filename for restore set newname for datafile 7 to "/u02/transport/test01.dbf"; # rename all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set plus the auxilliary tablespaces restore clone datafile 1, 2, 3, 6, 7; switch clone datafile all; #online the datafiles restored or flipped sql clone "alter database datafile 1 online"; #online the datafiles restored or flipped sql clone "alter database datafile 2 online"; #online the datafiles restored or flipped sql clone "alter database datafile 3 online"; #online the datafiles restored or flipped sql clone "alter database datafile 6 online"; #online the datafiles restored or flipped sql clone "alter database datafile 7 online"; # make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TSPITR", "TEST", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog; alter clone database open resetlogs; # PLUG HERE the creation of a temporary tablespace if export fails due to lack # of temporary space. # For example in Unix these two lines would do that: #sql clone "create tablespace aux_tspitr_tmp # datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K"; } 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 executing command: SET NEWNAME renamed temporary file 1 to /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 28-MAR-15 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_system_%u_.dbf restoring datafile 00002 to /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_undotbs1_%u_.dbf restoring datafile 00003 to /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_sysaux_%u_.dbf restoring datafile 00006 to /u02/transport/tspitr01.dbf restoring datafile 00007 to /u02/transport/test01.dbf channel ORA_AUX_DISK_1: reading from backup piece /u02/ora_test875392350_1001 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:26 Finished restore at 28-MAR-15 datafile 6 switched to datafile copy input datafile copy recid=22 stamp=875564535 filename=/u02/transport/tspitr01.dbf datafile 7 switched to datafile copy input datafile copy recid=23 stamp=875564535 filename=/u02/transport/test01.dbf datafile 1 switched to datafile copy input datafile copy recid=24 stamp=875564535 filename=/u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_system_bkf7513q_.dbf datafile 2 switched to datafile copy input datafile copy recid=25 stamp=875564535 filename=/u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_undotbs1_bkf7514q_.dbf datafile 3 switched to datafile copy input datafile copy recid=26 stamp=875564535 filename=/u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_sysaux_bkf75143_.dbf sql statement: alter database datafile 1 online sql statement: alter database datafile 2 online sql statement: alter database datafile 3 online sql statement: alter database datafile 6 online sql statement: alter database datafile 7 online Starting recover at 28-MAR-15 using channel ORA_AUX_DISK_1 starting media recovery archive log thread 1 sequence 80 is already on disk as file /u02/1_80_870806981.dbf archive log thread 1 sequence 81 is already on disk as file /u02/1_81_870806981.dbf archive log thread 1 sequence 82 is already on disk as file /u02/1_82_870806981.dbf archive log thread 1 sequence 83 is already on disk as file /u02/1_83_870806981.dbf archive log thread 1 sequence 84 is already on disk as file /u02/1_84_870806981.dbf archive log thread 1 sequence 85 is already on disk as file /u02/1_85_870806981.dbf archive log thread 1 sequence 86 is already on disk as file /u02/1_86_870806981.dbf archive log thread 1 sequence 87 is already on disk as file /u02/1_87_870806981.dbf archive log thread 1 sequence 88 is already on disk as file /u02/1_88_870806981.dbf archive log thread 1 sequence 89 is already on disk as file /u02/1_89_870806981.dbf archive log thread 1 sequence 90 is already on disk as file /u02/1_90_870806981.dbf archive log filename=/u02/1_80_870806981.dbf thread=1 sequence=80 archive log filename=/u02/1_81_870806981.dbf thread=1 sequence=81 archive log filename=/u02/1_82_870806981.dbf thread=1 sequence=82 archive log filename=/u02/1_83_870806981.dbf thread=1 sequence=83 archive log filename=/u02/1_84_870806981.dbf thread=1 sequence=84 archive log filename=/u02/1_85_870806981.dbf thread=1 sequence=85 archive log filename=/u02/1_86_870806981.dbf thread=1 sequence=86 archive log filename=/u02/1_87_870806981.dbf thread=1 sequence=87 archive log filename=/u02/1_88_870806981.dbf thread=1 sequence=88 archive log filename=/u02/1_89_870806981.dbf thread=1 sequence=89 archive log filename=/u02/1_90_870806981.dbf thread=1 sequence=90 media recovery complete, elapsed time: 00:00:56 Finished recover at 28-MAR-15 database opened contents of Memory Script: { #mark read only the tablespace that will be exported sql clone "alter tablespace TSPITR read only"; #mark read only the tablespace that will be exported sql clone "alter tablespace TEST read only"; # create directory for datapump export sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as '' /u02/transport''"; # export the tablespaces in the recovery set host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle\)\(ARGV0=oracleFmly\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=Fmly^'\)\)\(CONNECT_DATA=\(SID=Fmly\)\)\) as sysdba\" transport_tablespaces= TSPITR, TEST dumpfile= dmpfile.dmp directory= STREAMS_DIROBJ_DPDIR logfile= explog.log'; } executing Memory Script sql statement: alter tablespace TSPITR read only sql statement: alter tablespace TEST read only sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u02/transport'' Export: Release 10.2.0.5.0 - Production on Saturday, 28 March, 2015 20:23:43 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle)(ARGV0=oracleFmly)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=Fmly))(CONNECT_DATA=(SID=Fmly))) AS SYSDBA" transport_tablespaces= TSPITR, TEST dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is: /u02/transport/dmpfile.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:24:34 host command complete /* The following command may be used to import the tablespaces. Substitute values for and . impdp directory= dumpfile= 'dmpfile.dmp' transport_datafiles= /u02/transport/tspitr01.dbf, /u02/transport/test01.dbf */ -------------------------------------------------------------- -- Start of sample PL/SQL script for importing the tablespaces -------------------------------------------------------------- -- creating directory objects CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u02/transport/'; CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u02/transport'; /* PL/SQL Script to import the exported tablespaces */ DECLARE -- the datafiles tbs_files dbms_streams_tablespace_adm.file_set; cvt_files dbms_streams_tablespace_adm.file_set; -- the dumpfile to import dump_file dbms_streams_tablespace_adm.file; dp_job_name VARCHAR2(30) := NULL; -- names of tablespaces that were imported ts_names dbms_streams_tablespace_adm.tablespace_set; BEGIN -- dump file name and location dump_file.file_name := 'dmpfile.dmp'; dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR'; -- forming list of datafiles for import tbs_files( 1).file_name := 'tspitr01.dbf'; tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1'; tbs_files( 2).file_name := 'test01.dbf'; tbs_files( 2).directory_object := 'STREAMS$DIROBJ$1'; -- import tablespaces dbms_streams_tablespace_adm.attach_tablespaces( datapump_job_name => dp_job_name, dump_file => dump_file, tablespace_files => tbs_files, converted_files => cvt_files, tablespace_names => ts_names); -- output names of imported tablespaces IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN FOR i IN ts_names.first .. ts_names.last LOOP dbms_output.put_line('imported tablespace '|| ts_names(i)); END LOOP; END IF; END; / -- dropping directory objects DROP DIRECTORY STREAMS$DIROBJ$1; DROP DIRECTORY STREAMS$DIROBJ$DPDIR; -------------------------------------------------------------- -- End of sample PL/SQL script -------------------------------------------------------------- Removing automatic instance shutting down automatic instance Oracle instance shut down Automatic instance removed auxiliary instance file /u02/transport/cntrl_tspitr_TEST_Fmly.f deleted auxiliary instance file /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_system_bkf7513q_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_undotbs1_bkf7514q_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_sysaux_bkf75143_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_FMLY/datafile/o1_mf_temp_bkf79xd1_.tmp deleted auxiliary instance file /u02/transport/TSPITR_TEST_FMLY/onlinelog/o1_mf_1_bkf79khg_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_FMLY/onlinelog/o1_mf_2_bkf79ncf_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_FMLY/onlinelog/o1_mf_3_bkf79q23_.log deleted
執行表空間傳輸時為輔助資料檔案設定新檔名(configure auxname)
可以在RUN塊中使用configure auxname命令來為輔助資料檔案指定持久的儲存目錄:
RMAN> run 2> { 3> configure auxname for datafile '/u01/app/oracle/oradata/test/tspitr01.dbf' 4> to '/u02/transport/tspitr01.dbf'; 5> configure auxname for datafile '/u01/app/oracle/oradata/test/test01.dbf' 6> to '/u02/transport/test01.dbf'; 7> transport tablespace "TSPITR","TEST" 8> tablespace destination '/u02/transport' 9> auxiliary destination '/u02/transport' ; 10> } auxiliary name for datafile 6 set to: /u02/transport/tspitr01.dbf new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete auxiliary name for datafile 7 set to: /u02/transport/test01.dbf new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete Creating automatic instance, with SID='qsdg' using contents of file /u02/initaux.ora initialization parameters used for automatic instance: db_name=TEST compatible=10.2.0.5.0 db_block_size=8192 db_files=200 db_unique_name=tspitr_TEST_qsdg sga_target=180M processes=50 ifile=/u02/initaux.ora db_create_file_dest=/u02/transport control_files=/u02/transport/cntrl_tspitr_TEST_qsdg.f starting up automatic instance TEST Oracle instance started Total System Global Area 188743680 bytes Fixed Size 1272720 bytes Variable Size 167773296 bytes Database Buffers 16777216 bytes Redo Buffers 2920448 bytes Automatic instance created contents of Memory Script: { # set the until clause set until scn 1204735; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log for tspitr to a resent until time sql 'alter system archive log current'; # avoid unnecessary autobackups for structural changes during TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;'; # resync catalog after controlfile restore resync catalog; } executing Memory Script executing command: SET until clause Starting restore at 28-MAR-15 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: sid=47 devtype=DISK channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /u02/c-2168949517-20150326-07 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/c-2168949517-20150326-07 tag=TAG20150326T203351 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02 output filename=/u02/transport/cntrl_tspitr_TEST_qsdg.f Finished restore at 28-MAR-15 sql statement: alter database mount clone database sql statement: alter system archive log current sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; starting full resync of recovery catalog full resync complete contents of Memory Script: { # generated tablespace point-in-time recovery script # set the until clause set until scn 1204735; # set an omf destination filename for restore set newname for clone datafile 1 to new; # set an omf destination filename for restore set newname for clone datafile 2 to new; # set an omf destination filename for restore set newname for clone datafile 3 to new; # set an omf destination tempfile set newname for clone tempfile 1 to new; # set a destination filename for restore set newname for datafile 6 to "/u02/transport/tspitr01.dbf"; # set a destination filename for restore set newname for datafile 7 to "/u02/transport/test01.dbf"; # rename all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set plus the auxilliary tablespaces restore clone datafile 1, 2, 3, 6, 7; switch clone datafile all; #online the datafiles restored or flipped sql clone "alter database datafile 1 online"; #online the datafiles restored or flipped sql clone "alter database datafile 2 online"; #online the datafiles restored or flipped sql clone "alter database datafile 3 online"; #online the datafiles restored or flipped sql clone "alter database datafile 6 online"; #online the datafiles restored or flipped sql clone "alter database datafile 7 online"; # make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TSPITR", "TEST", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog; alter clone database open resetlogs; # PLUG HERE the creation of a temporary tablespace if export fails due to lack # of temporary space. # For example in Unix these two lines would do that: #sql clone "create tablespace aux_tspitr_tmp # datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K"; } 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 executing command: SET NEWNAME renamed temporary file 1 to /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_temp_%u_.tmp in control file Starting restore at 28-MAR-15 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_system_%u_.dbf restoring datafile 00002 to /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_undotbs1_%u_.dbf restoring datafile 00003 to /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_sysaux_%u_.dbf restoring datafile 00006 to /u02/transport/tspitr01.dbf restoring datafile 00007 to /u02/transport/test01.dbf channel ORA_AUX_DISK_1: reading from backup piece /u02/ora_test875392350_1001 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:25 Finished restore at 28-MAR-15 datafile 1 switched to datafile copy input datafile copy recid=22 stamp=875565174 filename=/u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_system_bkf7s1mn_.dbf datafile 2 switched to datafile copy input datafile copy recid=23 stamp=875565174 filename=/u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_undotbs1_bkf7s1n9_.dbf datafile 3 switched to datafile copy input datafile copy recid=24 stamp=875565174 filename=/u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_sysaux_bkf7s1mz_.dbf datafile 6 switched to datafile copy input datafile copy recid=25 stamp=875565174 filename=/u02/transport/tspitr01.dbf datafile 7 switched to datafile copy input datafile copy recid=26 stamp=875565174 filename=/u02/transport/test01.dbf sql statement: alter database datafile 1 online sql statement: alter database datafile 2 online sql statement: alter database datafile 3 online sql statement: alter database datafile 6 online sql statement: alter database datafile 7 online Starting recover at 28-MAR-15 using channel ORA_AUX_DISK_1 starting media recovery archive log thread 1 sequence 80 is already on disk as file /u02/1_80_870806981.dbf archive log thread 1 sequence 81 is already on disk as file /u02/1_81_870806981.dbf archive log thread 1 sequence 82 is already on disk as file /u02/1_82_870806981.dbf archive log thread 1 sequence 83 is already on disk as file /u02/1_83_870806981.dbf archive log thread 1 sequence 84 is already on disk as file /u02/1_84_870806981.dbf archive log thread 1 sequence 85 is already on disk as file /u02/1_85_870806981.dbf archive log thread 1 sequence 86 is already on disk as file /u02/1_86_870806981.dbf archive log thread 1 sequence 87 is already on disk as file /u02/1_87_870806981.dbf archive log thread 1 sequence 88 is already on disk as file /u02/1_88_870806981.dbf archive log thread 1 sequence 89 is already on disk as file /u02/1_89_870806981.dbf archive log thread 1 sequence 90 is already on disk as file /u02/1_90_870806981.dbf archive log thread 1 sequence 91 is already on disk as file /u02/1_91_870806981.dbf archive log filename=/u02/1_80_870806981.dbf thread=1 sequence=80 archive log filename=/u02/1_81_870806981.dbf thread=1 sequence=81 archive log filename=/u02/1_82_870806981.dbf thread=1 sequence=82 archive log filename=/u02/1_83_870806981.dbf thread=1 sequence=83 archive log filename=/u02/1_84_870806981.dbf thread=1 sequence=84 archive log filename=/u02/1_85_870806981.dbf thread=1 sequence=85 archive log filename=/u02/1_86_870806981.dbf thread=1 sequence=86 archive log filename=/u02/1_87_870806981.dbf thread=1 sequence=87 archive log filename=/u02/1_88_870806981.dbf thread=1 sequence=88 archive log filename=/u02/1_89_870806981.dbf thread=1 sequence=89 archive log filename=/u02/1_90_870806981.dbf thread=1 sequence=90 archive log filename=/u02/1_91_870806981.dbf thread=1 sequence=91 media recovery complete, elapsed time: 00:01:03 Finished recover at 28-MAR-15 database opened contents of Memory Script: { #mark read only the tablespace that will be exported sql clone "alter tablespace TSPITR read only"; #mark read only the tablespace that will be exported sql clone "alter tablespace TEST read only"; # create directory for datapump export sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as '' /u02/transport''"; # export the tablespaces in the recovery set host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle\)\(ARGV0=oracleqsdg\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=qsdg^'\)\)\(CONNECT_DATA=\(SID=qsdg\)\)\) as sysdba\" transport_tablespaces= TSPITR, TEST dumpfile= dmpfile.dmp directory= STREAMS_DIROBJ_DPDIR logfile= explog.log'; } executing Memory Script sql statement: alter tablespace TSPITR read only sql statement: alter tablespace TEST read only sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u02/transport'' Export: Release 10.2.0.5.0 - Production on Saturday, 28 March, 2015 20:34:37 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle)(ARGV0=oracleqsdg)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=qsdg))(CONNECT_DATA=(SID=qsdg))) AS SYSDBA" transport_tablespaces= TSPITR, TEST dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is: /u02/transport/dmpfile.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:35:50 host command complete /* The following command may be used to import the tablespaces. Substitute values for and . impdp directory= dumpfile= 'dmpfile.dmp' transport_datafiles= /u02/transport/tspitr01.dbf, /u02/transport/test01.dbf */ -------------------------------------------------------------- -- Start of sample PL/SQL script for importing the tablespaces -------------------------------------------------------------- -- creating directory objects CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u02/transport/'; CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u02/transport'; /* PL/SQL Script to import the exported tablespaces */ DECLARE -- the datafiles tbs_files dbms_streams_tablespace_adm.file_set; cvt_files dbms_streams_tablespace_adm.file_set; -- the dumpfile to import dump_file dbms_streams_tablespace_adm.file; dp_job_name VARCHAR2(30) := NULL; -- names of tablespaces that were imported ts_names dbms_streams_tablespace_adm.tablespace_set; BEGIN -- dump file name and location dump_file.file_name := 'dmpfile.dmp'; dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR'; -- forming list of datafiles for import tbs_files( 1).file_name := 'tspitr01.dbf'; tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1'; tbs_files( 2).file_name := 'test01.dbf'; tbs_files( 2).directory_object := 'STREAMS$DIROBJ$1'; -- import tablespaces dbms_streams_tablespace_adm.attach_tablespaces( datapump_job_name => dp_job_name, dump_file => dump_file, tablespace_files => tbs_files, converted_files => cvt_files, tablespace_names => ts_names); -- output names of imported tablespaces IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN FOR i IN ts_names.first .. ts_names.last LOOP dbms_output.put_line('imported tablespace '|| ts_names(i)); END LOOP; END IF; END; / -- dropping directory objects DROP DIRECTORY STREAMS$DIROBJ$1; DROP DIRECTORY STREAMS$DIROBJ$DPDIR; -------------------------------------------------------------- -- End of sample PL/SQL script -------------------------------------------------------------- Removing automatic instance shutting down automatic instance Oracle instance shut down Automatic instance removed auxiliary instance file /u02/transport/cntrl_tspitr_TEST_qsdg.f deleted auxiliary instance file /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_system_bkf7s1mn_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_undotbs1_bkf7s1n9_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_sysaux_bkf7s1mz_.dbf deleted auxiliary instance file /u02/transport/TSPITR_TEST_QSDG/datafile/o1_mf_temp_bkf7ycqg_.tmp deleted auxiliary instance file /u02/transport/TSPITR_TEST_QSDG/onlinelog/o1_mf_1_bkf7xw77_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_QSDG/onlinelog/o1_mf_2_bkf7xz96_.log deleted auxiliary instance file /u02/transport/TSPITR_TEST_QSDG/onlinelog/o1_mf_3_bkf7y29x_.log deleted
使用初始化引數來對傳輸表空間命名輔助資料檔案
可以在輔助例項引數檔案中使用log_file_name_convert和db_file_name_convert引數來控制輔助例項的聯機重做日誌和其它資料檔案的檔名
[oracle@oracle11g u02]$ vi initaux.ora shared_pool_size=150M control_files=('/u02/transport/control01.ctl') db_file_name_convert=('/u01/app/oracle/oradata/test/','/u02/transport/') log_file_name_convert=('/u01/app/oracle/oradata/test/','/u02/transport/')
RMAN> run 2> { 3> set auxiliary instance parameter file to '/u02/initaux.ora'; 4> transport tablespace "TSPITR","TEST" 5> tablespace destination '/u02/transport'; }6> executing command: SET auxiliary parameter file Creating automatic instance, with SID='psnl' using contents of file /u02/initaux.ora initialization parameters used for automatic instance: db_name=TEST compatible=10.2.0.5.0 db_block_size=8192 db_files=200 db_unique_name=tspitr_TEST_psnl sga_target=180M processes=50 ifile=/u02/initaux.ora #No auxiliary destination in use #Use default controlfile starting up automatic instance TEST Oracle instance started Total System Global Area 188743680 bytes Fixed Size 1272720 bytes Variable Size 167773296 bytes Database Buffers 16777216 bytes Redo Buffers 2920448 bytes Automatic instance created contents of Memory Script: { # set the until clause set until scn 1205073; # restore the controlfile restore clone controlfile; # mount the controlfile sql clone 'alter database mount clone database'; # archive current online log for tspitr to a resent until time sql 'alter system archive log current'; # avoid unnecessary autobackups for structural changes during TSPITR sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;'; # resync catalog after controlfile restore resync catalog; } executing Memory Script executing command: SET until clause Starting restore at 28-MAR-15 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: sid=47 devtype=DISK channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /u02/c-2168949517-20150326-07 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/c-2168949517-20150326-07 tag=TAG20150326T203351 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02 output filename=/u02/transport/control01.ctl Finished restore at 28-MAR-15 sql statement: alter database mount clone database sql statement: alter system archive log current sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; starting full resync of recovery catalog full resync complete contents of Memory Script: { # generated tablespace point-in-time recovery script # set the until clause set until scn 1205073; # set a destination filename for restore set newname for datafile 1 to "/u02/transport/system01.dbf"; # set a destination filename for restore set newname for datafile 2 to "/u02/transport/undotbs01.dbf"; # set a destination filename for restore set newname for datafile 3 to "/u02/transport/sysaux01.dbf"; # set a destination tempfile set newname for tempfile 1 to "/u02/transport/temp01.dbf"; # set a destination filename for restore set newname for datafile 6 to "/u02/transport/tspitr01.dbf"; # set a destination filename for restore set newname for datafile 7 to "/u02/transport/test01.dbf"; # rename all tempfiles switch clone tempfile all; # restore the tablespaces in the recovery set plus the auxilliary tablespaces restore clone datafile 1, 2, 3, 6, 7; switch clone datafile all; #online the datafiles restored or flipped sql clone "alter database datafile 1 online"; #online the datafiles restored or flipped sql clone "alter database datafile 2 online"; #online the datafiles restored or flipped sql clone "alter database datafile 3 online"; #online the datafiles restored or flipped sql clone "alter database datafile 6 online"; #online the datafiles restored or flipped sql clone "alter database datafile 7 online"; # make the controlfile point at the restored datafiles, then recover them recover clone database tablespace "TSPITR", "TEST", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog; alter clone database open resetlogs; # PLUG HERE the creation of a temporary tablespace if export fails due to lack # of temporary space. # For example in Unix these two lines would do that: #sql clone "create tablespace aux_tspitr_tmp # datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K"; } 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 executing command: SET NEWNAME Starting restore at 28-MAR-15 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backupset restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u02/transport/system01.dbf restoring datafile 00002 to /u02/transport/undotbs01.dbf restoring datafile 00003 to /u02/transport/sysaux01.dbf restoring datafile 00006 to /u02/transport/tspitr01.dbf restoring datafile 00007 to /u02/transport/test01.dbf channel ORA_AUX_DISK_1: reading from backup piece /u02/ora_test875392350_1001 channel ORA_AUX_DISK_1: restored backup piece 1 piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:45 Finished restore at 28-MAR-15 sql statement: alter database datafile 1 online sql statement: alter database datafile 2 online sql statement: alter database datafile 3 online sql statement: alter database datafile 6 online sql statement: alter database datafile 7 online Starting recover at 28-MAR-15 using channel ORA_AUX_DISK_1 starting media recovery archive log thread 1 sequence 80 is already on disk as file /u02/1_80_870806981.dbf archive log thread 1 sequence 81 is already on disk as file /u02/1_81_870806981.dbf archive log thread 1 sequence 82 is already on disk as file /u02/1_82_870806981.dbf archive log thread 1 sequence 83 is already on disk as file /u02/1_83_870806981.dbf archive log thread 1 sequence 84 is already on disk as file /u02/1_84_870806981.dbf archive log thread 1 sequence 85 is already on disk as file /u02/1_85_870806981.dbf archive log thread 1 sequence 86 is already on disk as file /u02/1_86_870806981.dbf archive log thread 1 sequence 87 is already on disk as file /u02/1_87_870806981.dbf archive log thread 1 sequence 88 is already on disk as file /u02/1_88_870806981.dbf archive log thread 1 sequence 89 is already on disk as file /u02/1_89_870806981.dbf archive log thread 1 sequence 90 is already on disk as file /u02/1_90_870806981.dbf archive log thread 1 sequence 91 is already on disk as file /u02/1_91_870806981.dbf archive log thread 1 sequence 92 is already on disk as file /u02/1_92_870806981.dbf archive log filename=/u02/1_80_870806981.dbf thread=1 sequence=80 archive log filename=/u02/1_81_870806981.dbf thread=1 sequence=81 archive log filename=/u02/1_82_870806981.dbf thread=1 sequence=82 archive log filename=/u02/1_83_870806981.dbf thread=1 sequence=83 archive log filename=/u02/1_84_870806981.dbf thread=1 sequence=84 archive log filename=/u02/1_85_870806981.dbf thread=1 sequence=85 archive log filename=/u02/1_86_870806981.dbf thread=1 sequence=86 archive log filename=/u02/1_87_870806981.dbf thread=1 sequence=87 archive log filename=/u02/1_88_870806981.dbf thread=1 sequence=88 archive log filename=/u02/1_89_870806981.dbf thread=1 sequence=89 archive log filename=/u02/1_90_870806981.dbf thread=1 sequence=90 archive log filename=/u02/1_91_870806981.dbf thread=1 sequence=91 archive log filename=/u02/1_92_870806981.dbf thread=1 sequence=92 media recovery complete, elapsed time: 00:01:06 Finished recover at 28-MAR-15 database opened contents of Memory Script: { #mark read only the tablespace that will be exported sql clone "alter tablespace TSPITR read only"; #mark read only the tablespace that will be exported sql clone "alter tablespace TEST read only"; # create directory for datapump export sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as '' /u02/transport''"; # export the tablespaces in the recovery set host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle\)\(ARGV0=oraclepsnl\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=psnl^'\)\)\(CONNECT_DATA=\(SID=psnl\)\)\) as sysdba\" transport_tablespaces= TSPITR, TEST dumpfile= dmpfile.dmp directory= STREAMS_DIROBJ_DPDIR logfile= explog.log'; } executing Memory Script sql statement: alter tablespace TSPITR read only sql statement: alter tablespace TEST read only sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u02/transport'' Export: Release 10.2.0.5.0 - Production on Saturday, 28 March, 2015 20:48:44 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle)(ARGV0=oraclepsnl)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=psnl))(CONNECT_DATA=(SID=psnl))) AS SYSDBA" transport_tablespaces= TSPITR, TEST dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is: /u02/transport/dmpfile.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:49:41 host command complete /* The following command may be used to import the tablespaces. Substitute values for and . impdp directory= dumpfile= 'dmpfile.dmp' transport_datafiles= /u02/transport/tspitr01.dbf, /u02/transport/test01.dbf */ -------------------------------------------------------------- -- Start of sample PL/SQL script for importing the tablespaces -------------------------------------------------------------- -- creating directory objects CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u02/transport/'; CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u02/transport'; /* PL/SQL Script to import the exported tablespaces */ DECLARE -- the datafiles tbs_files dbms_streams_tablespace_adm.file_set; cvt_files dbms_streams_tablespace_adm.file_set; -- the dumpfile to import dump_file dbms_streams_tablespace_adm.file; dp_job_name VARCHAR2(30) := NULL; -- names of tablespaces that were imported ts_names dbms_streams_tablespace_adm.tablespace_set; BEGIN -- dump file name and location dump_file.file_name := 'dmpfile.dmp'; dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR'; -- forming list of datafiles for import tbs_files( 1).file_name := 'tspitr01.dbf'; tbs_files( 1).directory_object := 'STREAMS$DIROBJ$1'; tbs_files( 2).file_name := 'test01.dbf'; tbs_files( 2).directory_object := 'STREAMS$DIROBJ$1'; -- import tablespaces dbms_streams_tablespace_adm.attach_tablespaces( datapump_job_name => dp_job_name, dump_file => dump_file, tablespace_files => tbs_files, converted_files => cvt_files, tablespace_names => ts_names); -- output names of imported tablespaces IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN FOR i IN ts_names.first .. ts_names.last LOOP dbms_output.put_line('imported tablespace '|| ts_names(i)); END LOOP; END IF; END; / -- dropping directory objects DROP DIRECTORY STREAMS$DIROBJ$1; DROP DIRECTORY STREAMS$DIROBJ$DPDIR; -------------------------------------------------------------- -- End of sample PL/SQL script -------------------------------------------------------------- Removing automatic instance shutting down automatic instance Oracle instance shut down Automatic instance removed auxiliary instance file /u02/transport/control01.ctl deleted auxiliary instance file /u02/transport/system01.dbf deleted auxiliary instance file /u02/transport/undotbs01.dbf deleted auxiliary instance file /u02/transport/sysaux01.dbf deleted auxiliary instance file /u02/transport/temp01.dbf deleted auxiliary instance file /u02/transport/redo01.log deleted auxiliary instance file /u02/transport/redo02.log deleted auxiliary instance file /u02/transport/redo03.log deleted
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29702473/viewspace-1480073/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 實戰RMAN備份傳輸表空間
- 使用Oracle可傳輸表空間的特性複製資料(7)實戰RMAN備份傳輸表空間Oracle
- Oracle 傳輸表空間-RmanOracle
- 使用RMAN實現可傳輸的表空間
- 傳輸表空間操作-OracleOracle
- RMAN說,我能備份(3)--RMAN全庫備份和表空間備份
- oracle監控表空間,JOB,rman備份Oracle
- 【傳輸表空間】使用 EXPDP/IMPDP工具的傳輸表空間完成資料遷移
- 透過rman備份system系統表空間
- Oracle RMAN備份為什麼會大量使用temp表空間?Oracle
- Oracle各種表空間Oracle
- 11g使用增量備份來執行跨平臺傳輸表空間減少停機時間(xtts_rman)TTS
- 【傳輸表空間】使用 EXPDP/IMPDP工具的傳輸表空間完成資料遷移[轉]
- 【TTS】傳輸表空間Linux ->AIX 基於rmanTTSLinuxAI
- RMAN跨平臺傳輸表空間(different Endian)
- RMAN跨平臺傳輸表空間(same endian)
- Oracle 10g的可傳輸表空間操作Oracle 10g
- MySQL 傳輸表空間MySql
- Oracle 表空間傳輸Oracle
- oracle表空間傳輸Oracle
- Oracle傳輸表空間Oracle
- MySQL表空間傳輸MySql
- 如何用rman 不備份只讀表空間的資料
- Oracle 12C使用備份集執行只讀表空間的跨平臺傳輸Oracle
- 傳輸表空間(TTS) - 不同位元組序平臺 RMAN Convert - 6 使用RMAN增量備減少停機時間TTS
- RMAN跨平臺傳輸資料庫和表空間資料庫
- 【TTS】傳輸表空間AIX->linux基於rmanTTSAILinux
- 非系統表空間損壞,rman備份恢復
- 基於可傳輸表空間的表空間遷移
- mysql之 表空間傳輸MySql
- Oracle傳輸表空間(TTS)OracleTTS
- 總結-表空間傳輸
- RMAN簡單演示 備份各種檔案
- RMAN跨平臺可傳輸表空間和資料庫資料庫
- 通過RMAN-transport獲取傳輸表空間檔案
- oracle 12c 使用RMAN的傳輸表空間功能在PDB之間遷移資料Oracle
- 跨平臺表空間遷移(傳輸表空間)
- MySQL傳輸表空間的簡單使用方法MySql