確認環境:
源庫:
系統:RedHat企業版5.4
資料庫版本:Oracle 10.2.0.1.0
IP:10.37.100.100
目標庫:
系統:RedHat企業版5.4
資料庫版本:ORACLE 10.2.0.3.0
IP:10.37.100.101
需要傳輸的資料表空間:TTS_TEST
檢查一下環境:
源庫上查看版本支援情況:
SQL> select db.name,db.platform_name,tp.endian_format
2 from v$transportable_platform tp,v$database db
3 where tp.platform_name=db.platform_name
4 /
NAME PLATFORM_NAME ENDIAN_FORMAT
--------- -------------------- --------------
ORCL Linux IA (32-bit) Little
查看資料庫版本:
SQL> select version from v$instance;
VERSION
-----------------
10.2.0.1.0
備庫上查看版本情況:
SQL> select db.name,db.platform_name,tp.endian_format
2 from v$transportable_platform tp,v$database db
3 where tp.platform_name=db.platform_name
4 /
NAME PLATFORM_NAME ENDIAN_FORMAT
--------- -------------------- --------------
ORCL Linux IA (32-bit) Little
源庫上需要有整庫和所有歸檔日誌的備份
RMAN> backup database plus archivelog format '/u01/rman_backup/all_database_bak_%T_%t.bak';
RMAN> transport tablespace tts_test
2> tablespace destination '/u01/tts_dir/td'
3> auxiliary destination '/u01/tts_dir/ad';
此時傳輸資料表空間所需的資料檔案,記錄檔,傳輸集及匯入指令碼均已產生在tablepsace desnation目錄下,而auxilibary desnation路徑下的臨時檔案已經被刪除
[oracle@localhost td]$ cd /u01/tts_dir/td/
[oracle@localhost td]$ ls
dmpfile.dmp explog.log impscrpt.sql tts01.dbf tts02.dbf
[oracle@localhost td]$ cd /u01/tts_dir/ad/
[oracle@localhost ad]$ ls
TSPITR_ORCL_MWWE
[oracle@localhost ad]$ cd TSPITR_ORCL_MWWE/
[oracle@localhost TSPITR_ORCL_MWWE]$ ls
datafile onlinelog
[oracle@localhost TSPITR_ORCL_MWWE]$ cd datafile/
[oracle@localhost datafile]$ ls
[oracle@localhost datafile]$ cd ../onlinelog/
[oracle@localhost onlinelog]$ ls
將tablepsace desnation路徑下產生的所有檔案copy到目標庫:
[oracle@localhost ~]$ scp 10.37.100.100:/u01/tts_dir/td/* /u01/tts_dir/
oracle@10.37.100.100's password:
dmpfile.dmp 100% 76KB 76.0KB/s 00:00
explog.log 100% 1226 1.2KB/s 00:00
impscrpt.sql 100% 2175 2.1KB/s 00:00
tts01.dbf 100% 20MB 20.0MB/s 00:01
tts02.dbf 100% 20MB 20.0MB/s 00:01
SQL> @/u01/tts_dir/impscrpt.sql
Directory created.
Directory created.
DECLARE
*
ERROR at line 1:
ORA-39002: invalid operation
ORA-06512: at "SYS.DBMS_STREAMS_TABLESPACE_ADM", line 2006
ORA-06512: at line 20
Directory dropped.
Directory dropped.
報錯的原因是目標庫的傳輸集路徑跟源庫的不一樣,可以將傳輸集複製到相同的路徑下,或者去修改一下impscrpt.sql中的路徑:
[oracle@localhost tts_dir]$ vi impscrpt.sql
將一下兩個路徑修改成目標庫下的傳輸集路徑即可:
CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/u01/tts_dir/';
CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS '/u01/tts_dir/';
再次執行指令碼匯入:
SQL> @/u01/tts_dir/impscrpt.sql
Directory created.
Directory created.
PL/SQL procedure successfully completed.
Directory dropped.
Directory dropped.
也可以直接使用inpdp命令匯入(這種匯入可以使用remap_schma參數來修改資料表空間的所屬主)
[oracle@localhost tts_dir]$ impdp system/oracle dumpfile=dmpfile.dmp directory=tts_dir nologf
ile=y transport_datafiles=/u01/tts_dir/tts01.dbf,/u01/tts_dir/tts02.dbf remap_schema=tts:xtt;
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** dumpfile=dmpfile.dmp directory=tts_dir nologfile=y transport_datafiles=/u01/tts_dir/tts01.dbf,/u01/tts_dir/tts02.dbf remap_schema=tts:xtt
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 "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 10:24:37
查看一下結果:
SQL> conn xtt/oracle
Connected.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TEST TABLE
DG_TEST TABLE
STD_TABLE_1 TABLE
STD_TABLE TABLE