select * from t1;
1.
2. ID NAME
3. ---------- ------------------------------
4. 1 AAAAA
5. 2 BBBBB
3、在source端和target端创建 backup 的目录
[oracle@normal ~]$ mkdir -p /u01/backup
[oracle@normal ~]$ ls -l /u01
total 24
drwxr-xr-x 3 oracle oinstall 4096 Jul 28 12:31 app
drwxr-xr-x 2 oracle oinstall 4096 Sep 14 16:21 backup
SQL> show user
USER is "SYS"
SQL> create directory backup as '/u01/backup';
Directory created.
SQL> col owner format a5
SQL> col directory_name format a25
SQL> col DIRECTORY_PATH format a50
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
----- ------------------------- --------------------------------------------------
SYS BACKUP /u01/backup
SYS OUTLN_DIR /home/oracle
SYS DATA_PUMP_DIR /u01/app/oracle/product/11.2.0/db_1/rdbms/log/
SYS ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/11.2.0/db_1/ccr/state
SQL> GRANT read, write ON DIRECTORY backup TO source_test;
Grant succeeded.
--在target端
[oracle@test ~]$ mkdir -p /u01/backup
[oracle@test ~]$ ls -l /u01
total 24
drwxr-xr-x 3 oracle oinstall 4096 Aug 28 09:09 app
drwxr-xr-x 2 oracle oinstall 4096 Sep 14 16:40 backup
SQL> show user
USER is "SYS"
SQL> create directory backup as '/u01/backup';
Directory created.
SQL> col owner format a5
SQL> col directory_name format a25
SQL> col DIRECTORY_PATH format a50
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
----- ------------------------- --------------------------------------------------
SYS BACKUP /u01/backup
SYS OUTLN_DIR /home/oracle
SYS DATA_PUMP_DIR /u01/app/oracle/product/11.2.0/db_1/rdbms/log/
SYS ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/11.2.0/db_1/ccr/state
SQL> GRANT read, write ON DIRECTORY backup TO target_test;
Grant succeeded.
4、检查表空间自包含(就是改表空间里的数据没有和其他表空间数据有关联,如果有关联会报错)
SQL> execute dbms_tts.transport_set_check('TSET', TRUE);
PL/SQL procedure successfully completed.
--查看自包含验证结果:
SQL> select * from transport_set_violations;
no rows selected
--没有记录说明没有错
5、将表空间TSET设置成read?-only,生成Transportable Tablespace Set之后就可以改成read write 了。
SQL> alter tablespace TSET read only;
Tablespace altered.
select tablespace_name, status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMPTS1 ONLINE
USERS ONLINE
OUTLN ONLINE
TSET READ ONLY
7 rows selected.
6、生成:Transportable Tablespace Set ,
Transportable Tablespace Set有两部分:
1.expdp 导出的表空间的metadata
2.还有就是表空间对应的数据文件
--expdp 导出的表空间的metadata
[oracle@normal normal]$ pwd
/u01/app/oracle/oradata/normal
[oracle@normal normal]$ ll
total 2294664
-rw-r----- 1 oracle oinstall 9781248 Sep 14 16:46 control01.ctl
drwx------ 2 oracle oinstall 16384 Aug 22 12:44 lost+found
-rw-r----- 1 oracle oinstall 20979712 Sep 14 15:52 outln01.dbf
-rw-r----- 1 oracle oinstall 52429312 Sep 14 16:45 redo01a.log
-rw-r----- 1 oracle oinstall 52429312 Sep 14 16:45 redo01b.log
-rw-r----- 1 oracle oinstall 52429312 Sep 14 15:52 redo02a.log
-rw-r----- 1 oracle oinstall 52429312 Sep 14 15:52 redo02b.log
-rw-r----- 1 oracle oinstall 52429312 Sep 14 15:52 redo03a.log
-rw-r----- 1 oracle oinstall 52429312 Sep 14 15:52 redo03b.log
-rw-r--r-- 1 oracle oinstall 22633 Aug 22 17:00 su.lst
-rw-r----- 1 oracle oinstall 340795392 Sep 14 16:40 sysaux01.dbf
-rw-r----- 1 oracle oinstall 340795392 Sep 14 16:43 system01.dbf
-rw-r----- 1 oracle oinstall 314580992 Sep 14 16:43 system02.dbf
-rw-r----- 1 oracle oinstall 20979712 Sep 14 15:53 temp01.dbf
-rw-r----- 1 oracle oinstall 52436992 Sep 14 15:53 temp02.dbf
-rw-r----- 1 oracle oinstall 52436992 Sep 14 16:31 test01.dbf
-rw-r----- 1 oracle oinstall 209723392 Sep 14 16:43 undotbs01.dbf
-rw-r----- 1 oracle oinstall 209723392 Sep 14 16:40 undotbs02.dbf
-rw-r----- 1 oracle oinstall 524296192 Sep 14 15:52 users01.dbf
[oracle@normal normal]$ expdp dumpfile=test01.dmp directory=backup
transport_tablespaces=TSET transport_full_check=y logfile=TSET.log
Export: Release 11.2.0.3.0 - Production on Sun Sep 14 16:54:30 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Username: / as sysdba
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": /********/ AS SYSDBA dumpfile=test01.dmp directory=backup transport_tablespaces=TSET transport_full_check=y logfile=TSET.log
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
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:
/u01/backup/test01.dmp
******************************************************************************
Datafiles required for transportable tablespace TSET:
/u01/app/oracle/oradata/normal/test01.dbf
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 16:55:13
[oracle@normal normal]$ ls -l /u01/backup/
total 80
-rw-r----- 1 oracle oinstall 77824 Sep 14 16:55 test01.dmp
-rw-r--r-- 1 oracle oinstall 1160 Sep 14 16:55 TSET.log
7、将Transportable Tablespace set 传送到Target端
1)将表空间test 对应的数据文件copy到Target 对应的ORADATA目录下。
2)将expdp 导出的表空间metadta 数据copy 到Target 端的backup 目录下
--将表空间test 对应的数据文件copy到Target 对应的ORADATA目录下,这个路径可以和source不样。
[oracle@normal normal]$ scp /u01/backup/test01.dmp 192.168.137.12:/u01/backup
oracle@192.168.137.12 s password:
test01.dmp 100% 76KB 76.0KB/s 00:00
--将expdp 导出的表空间metadta 数据copy 到Target 端的backup 目录下
[oracle@normal normal]$ scp test01.dbf 192.168.137.12:/u01/app/oracle/oradata/normal/test01.dbf
oracle@192.168.137.12 s password:
test01.dbf 100% 50MB 16.7MB/s 00:03
--在target端查看文件是否已经传输
[oracle@test ~]$ ll /u01/backup/
total 76
-rw-r----- 1 oracle oinstall 77824 Sep 14 17:03 test01.dmp
[oracle@test ~]$ ll $ORACLE_BASE/oradata/normal/test01.dbf
-rw-r----- 1 oracle oinstall 52436992 Sep 14 17:04 /u01/app/oracle/oradata/normal/test01.dbf
8、在Target 系统上Import 表空间的metadata(使用target_test用户,需要用到remap_schema)
[oracle@test ~]$ impdp directory=backup dumpfile=test01.dmp transport_datafiles=/u01/app/oracle/oradata/normal/test01.dbf remap_schema=source_test:target_test logfile=test.log
Import: Release 11.2.0.3.0 - Production on Sun Sep 14 17:09:25 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Username: / as sysdba
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded