將Linux平臺上的源數據庫中的tspitr與test表空間傳輸到AIX平臺上。並在源主機上使用目錄/u02/transport來存儲被轉換的數據文件。操做步驟以下:
1.將要被傳輸的表空間tspitr與test設置爲只讀web
SQL> alter tablespace tspitr read only; Tablespace altered. SQL> alter tablespace test read only; Tablespace altered.
2.檢查源平臺與目標平臺信息支不支持傳輸操做
數據庫所支持的平臺信息:sql
SQL> select platform_name,endian_format from v$transportable_platform; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- Solaris[tm] OE (32-bit) Big Solaris[tm] OE (64-bit) Big Microsoft Windows IA (32-bit) Little Linux IA (32-bit) Little AIX-Based Systems (64-bit) Big HP-UX (64-bit) Big HP Tru64 UNIX Little HP-UX IA (64-bit) Big Linux IA (64-bit) Little HP Open VMS Little Microsoft Windows IA (64-bit) Little IBM zSeries Based Linux Big Linux x86 64-bit Little Apple Mac OS Big Microsoft Windows x86 64-bit Little Solaris Operating System (x86) Little IBM Power Based Linux Big Solaris Operating System (x86-64) Little HP IA Open VMS Little
源平臺:數據庫
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT ----------------------------------------------------------------------------------------------------- -------------- Linux 64-bit for AMD Little
目標平臺oracle
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- AIX-Based Systems (64-bit) Big
3.確認要被傳輸的表空間是不是自包含表空間(TSPITR,TEST):app
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
若是沒有行選擇,表示該表空間只包含表數據,能夠傳輸。ide
4.記錄表空間傳輸前表tspitr與test中的記錄:工具
SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
5.使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.測試
[oracle@oracle11g ~]export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' [oracle@oracle11g ~]rman target/ Recovery Manager: Release 10.2.0.5.0 - Production on Mon Mar 30 10:35:41 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: TEST (DBID=2168949517) RMAN> convert tablespace "TSPITR","TEST" 2> to platform 'AIX-Based Systems (64-bit)' 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 10:37:27 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=141 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/test/tspitr01.dbf converted datafile=/u02/transport/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/test/test01.dbf converted datafile=/u02/transport/data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 Finished backup at 2015-03-30 10:37:45 [oracle@oracle11g transport]$ ls -lrt total 112776 -rw-r----- 1 oracle oinstall 104865792 Mar 30 10:37 data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 -rw-r----- 1 oracle oinstall 10493952 Mar 30 10:37 data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo
6.使用導出工具建立傳輸表空間元數據dump文件spa
SQL> create or replace directory test_dump as '/u02/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [oracle@oracle11g dump_test]$ expdp \'sys/zzh_2046@test as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.5.0 - Production on Monday, 30 March, 2015 10:57: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": "sys/********@test AS SYSDBA" directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 10:57:55 [oracle@oracle11g dump_test]ls -lrt -rw-r----- 1 oracle oinstall 960 Mar 30 15:23 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 15:23 tspitr_test.dmp
7.將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中orm
ftp> put data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 200 PORT command successful. 150 Opening data connection for data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v 8. 226 Transfer complete. ftp: 發送 104865792 字節,用時 8.86秒 11839.88千字節/秒。 ftp> put data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo 200 PORT command successful. 150 Opening data connection for data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo. 226 Transfer complete. ftp: 發送 10493952 字節,用時 0.90秒 11659.95千字節/秒。 ftp> put tspitr_test.dmp 200 PORT command successful. 150 Opening data connection for tspitr_test.dmp. 226 Transfer complete. [IBMP740-1:oracle:/yb_oradata]$ls -lrt -rwxrwxrwx 1 oracle dba 104865792 Mar 30 12:42 data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 -rwxrwxrwx 1 oracle dba 10493952 Mar 30 12:42 data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo -rwxrwxrwx 1 oracle dba 98304 Mar 30 12:42 tspitr_test.dmp
8.將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [IBMP740-1:oracle]$impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo,/yb_oradata/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 11:45:48 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo,/yb_oradata/transport/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK ORA-39123: Data Pump transportable tablespace job aborted ORA-00721: changes by release 10.2.0.5.0 cannot be used by release 10.2.0.3.0 Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" stopped due to fatal error at 11:45:53
出錯緣由是由於源數據庫的compatible=10.2.0.5.0,目標數據庫的compatible=10.2.0.3.0這裏在導出使用version=10.2.0.3.0導出元數據後再執行導出也是一樣會報這個錯誤,由於這裏不是邏輯導出,而是傳輸表空間,因此version參數不起做用。因此想修改源數據庫的compatible參數爲10.2.0.3.0,但在10g之後,compatible參數只能增大不能減小。
SQL> show parameter compatible
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
compatible string 10.2.0.5.0
SQL> alter system set compatible='10.2.0.3.0' scope=spfile;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1272600 bytes
Variable Size 109053160 bytes
Database Buffers 54525952 bytes
Redo Buffers 2920448 bytes
ORA-00201: control file version 10.2.0.5.0 incompatible with ORACLE version
10.2.0.3.0
ORA-00202: control file: '/u01/app/oracle/oradata/test/control01.ctl'
在將源數據庫的compatible參數修改成10.2.0.3.0後沒法啓動數據庫。
這裏是從10.2.0.5(源數據庫的compatible參數爲10.2.0.5.0)向10.2.0.4(這裏目標數據庫中的compatible參數卻爲10.2.0.3.0,不是10.2.0.4.0)跨平臺傳輸表空間不會成功,也就是從高版本向低版本傳輸表空間不能成功。但從低版本向高版本傳輸表空間是能夠成功,例以下面的示例:
咱們要將Linux平臺上的源數據庫中的tspitr與test表空間傳輸到AIX平臺上。並在源主機上使用目錄/u02/transport來存儲被轉換的數據文件。操做步驟以下:
1.將要被傳輸的表空間tspitr與test設置爲只讀
SQL> alter tablespace tspitr read only; Tablespace altered. SQL> alter tablespace test read only; Tablespace altered.
2.檢查源平臺與目標平臺信息支不支持傳輸操做
數據庫所支持的平臺信息:
SQL> select platform_name,endian_format from v$transportable_platform; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- Solaris[tm] OE (32-bit) Big Solaris[tm] OE (64-bit) Big Microsoft Windows IA (32-bit) Little Linux IA (32-bit) Little AIX-Based Systems (64-bit) Big HP-UX (64-bit) Big HP Tru64 UNIX Little HP-UX IA (64-bit) Big Linux IA (64-bit) Little HP Open VMS Little Microsoft Windows IA (64-bit) Little IBM zSeries Based Linux Big Linux x86 64-bit Little Apple Mac OS Big Microsoft Windows x86 64-bit Little Solaris Operating System (x86) Little IBM Power Based Linux Big Solaris Operating System (x86-64) Little HP IA Open VMS Little
源平臺:
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT ----------------------------------------------------------------------------------------------------- -------------- Linux 64-bit for AMD Little
目標平臺
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- AIX-Based Systems (64-bit) Big
3.確認要被傳輸的表空間是不是自包含表空間(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
若是沒有行選擇,表示該表空間只包含表數據,能夠傳輸。
4.記錄表空間傳輸前表tspitr與test中的記錄:
SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
5.使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.
[oracle@weblogic28 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' [oracle@weblogic28 ~]$ rman target/ Recovery Manager: Release 10.2.0.1.0 - Production on Mon Mar 30 15:16:38 2015 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: JYTEST (DBID=3911337604) RMAN> convert tablespace "TSPITR","TEST" to platform 'AIX-Based Systems (64-bit)' 2> 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 15:17:09 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=134 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/jytest/tspitr01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/jytest/test01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 Finished backup at 2015-03-30 15:17:12 [root@weblogic28 transport]# ls -lrt total 102528 -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn
6.使用導出工具建立傳輸表空間元數據dump文件
SQL> create or replace directory test_dump as '/u02/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [oracle@weblogic28 ~]$ expdp \'sys/system as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.1.0 - 64bit Production on Monday, 30 March, 2015 15:23:19 Copyright (c) 2003, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": 'sys/******** AS SYSDBA' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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: /u02/transport/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 15:23:29 [root@weblogic28 transport]# ls -lrt total 102624 -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn -rw-r----- 1 oracle oinstall 960 Mar 30 15:23 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 15:23 tspitr_test.dmp
7.將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中
ftp> get data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4497 seconds (1.139e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm remote: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm ftp> get data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4518 seconds (1.133e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn remote: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn ftp> get tspitr_test.dmp 200 PORT command successful. 150 Opening BINARY mode data connection for tspitr_test.dmp (90112 bytes). 226 Transfer complete. 90112 bytes received in 0.001825 seconds (4.822e+04 Kbytes/s) local: tspitr_test.dmp remote: tspitr_test.dmp [IBMP740-1:oracle:/yb_oradata/transport]$ls -lrt total 205008 -rwxrwxrwx 1 oracle dba 52436992 Mar 30 15:06 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm -rwxrwxrwx 1 oracle dba 52436992 Mar 30 15:06 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn -rwxrwxrwx 1 oracle dba 90112 Mar 30 15:07 tspitr_test.dmp
8.將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. IBMP740-1:oracle:/yb_oradata/transport]impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 15:09:38 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 15:09:42 [IBMP740-1:oracle:/yb_oradata/transport]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 16:36:19 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 10.2.0.3.0 SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
能夠看到,從10.2.0.1(compatible=10.2.0.1.0)向10.2.0.4(compatible=10.2.0.3.0)跨平臺和字節序傳輸表空間是能夠執行成功。
爲了從10.2.0.5向10.2.0.4(compatible=10.2.0.3.0)跨平臺傳輸表空間,我這裏測試一下將10.2.0.1源數據庫升級到 10.2.0.5但compatible設置爲10.2.0.1.0或小於目標數據庫的compatible=10.2.0.3.0來進行測試。
[oracle@weblogic28 ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.5.0 - Production on Mon Mar 30 19:17:59 2015 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select version from v$instance; VERSION ----------------- 10.2.0.5.0 SQL> show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 10.2.0.1.0
將源數據庫從10.2.0.1升級到10.2.0.5後compatible參數仍是爲10.2.0.1.0
使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.
[oracle@weblogic28 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' [oracle@weblogic28 ~]$ rman target/ Recovery Manager: Release 10.2.0.5.0 - Production on Mon Mar 30 19:21:39 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: JYTEST (DBID=3911337604) RMAN> convert tablespace "TSPITR","TEST" 2> to platform 'AIX-Based Systems (64-bit)' 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 19:22:01 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=148 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/jytest/tspitr01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/jytest/test01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03 Finished backup at 2015-03-30 19:22:08
使用導出工具建立傳輸表空間元數據dump文件
SQL> create or replace directory test_dump as '/u02/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [oracle@weblogic28 ~]$ expdp \'sys/system as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.5.0 - 64bit Production on Monday, 30 March, 2015 19:23:47 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": "sys/******** AS SYSDBA" directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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: /u02/transport/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 19:24:00 [oracle@weblogic28 transport]$ ls -lrt total 102624 -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:22 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:22 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt -rw-r--r-- 1 oracle oinstall 986 Mar 30 19:24 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 19:24 tspitr_test.dmp
將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中
ftp> get data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4462 seconds (1.148e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt remote: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt ftp> get data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4458 seconds (1.149e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq remote: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq ftp> get tspitr_test.dmp 200 PORT command successful. 150 Opening BINARY mode data connection for tspitr_test.dmp (90112 bytes). 226 Transfer complete. 90112 bytes received in 0.00183 seconds (4.809e+04 Kbytes/s) local: tspitr_test.dmp remote: tspitr_test.dmp [IBMP740-1:oracle:/yb_oradata/transport]$rm tspitr_test.log [IBMP740-1:oracle:/yb_oradata/transport]$ls -lrt total 205008 -rw-r--r-- 1 oracle dba 52436992 Mar 30 19:08 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt -rw-r--r-- 1 oracle dba 52436992 Mar 30 19:08 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq -rw-r--r-- 1 oracle dba 90112 Mar 30 19:08 tspitr_test.dmp
將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [IBMP740-1:oracle:/yb_oradata/transport]$impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 19:12:27 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 19:12:33 SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
能夠看到執行成功。雖然源數據庫是10.2.0.5,但其compatible爲10.2.0.1.0,而目標數據庫是10.2.0.4,其compatible參數爲10.2.0.3.0,傳輸表空間是能成功執行的。
下面將源數據庫的compatible修改成10.2.0.3.0(與目標數據庫的compatible同樣)
[oracle@weblogic28 dbs]$ vi initjytest.ora 省.... *.compatible='10.2.0.3.0' SQL> startup pfile='/u01/app/oracle/product/10.2.0/db/dbs/initjytest.ora'; ORACLE instance started. Total System Global Area 1073741824 bytes Fixed Size 2101736 bytes Variable Size 335547928 bytes Database Buffers 729808896 bytes Redo Buffers 6283264 bytes Database mounted. Database opened. SQL> show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 10.2.0.3.0
使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.
[oracle@weblogic28 dbs]$ rman target/ Recovery Manager: Release 10.2.0.5.0 - Production on Mon Mar 30 19:47:07 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: JYTEST (DBID=3911337604) RMAN> convert tablespace "TSPITR","TEST" 2> to platform 'AIX-Based Systems (64-bit)' 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 19:47:28 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=141 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/jytest/tspitr01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/jytest/test01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 Finished backup at 2015-03-30 19:47:31
使用導出工具建立傳輸表空間元數據dump文件
[oracle@weblogic28 dbs]$ expdp \'sys/system as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.5.0 - 64bit Production on Monday, 30 March, 2015 19:48:36 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": "sys/******** AS SYSDBA" directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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: /u02/transport/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 19:48:50 [oracle@weblogic28 transport]$ ls -lrt total 102624 -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:47 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:47 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i -rw-r--r-- 1 oracle oinstall 986 Mar 30 19:48 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 19:48 tspitr_test.dmp
將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中
ftp> get data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4461 seconds (1.148e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h remote: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h ftp> get data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4481 seconds (1.143e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i remote: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i ftp> get tspitr_test.dmp 200 PORT command successful. 150 Opening BINARY mode data connection for tspitr_test.dmp (90112 bytes). 226 Transfer complete. 90112 bytes received in 0.001821 seconds (4.833e+04 Kbytes/s) local: tspitr_test.dmp remote: tspitr_test.dmp
將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [IBMP740-1:oracle:/yb_oradata/transport]$impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 19:32:30 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 19:32:32
能夠看到,將源數據庫10.2.0.5的compatible設置爲10.2.0.3.0與目標數據庫10.2.0.4的compatible同樣,執行傳輸表空間是能夠執行成功的。
以前使用pfile參數文件參源數據庫的compatible參數從10.2.0.1.0修改成10.2.0.3.0了,如今將其修改成10.2.0.1.0,並從新使用pfile文件啓動源數據庫會報錯。
[oracle@weblogic28 dbs]$ vi initjytest.ora 省.... *.compatible='10.2.0.1.0' SQL> startup pfile='/u01/app/oracle/product/10.2.0/db/dbs/initjytest.ora'; ORACLE instance started. Total System Global Area 1073741824 bytes Fixed Size 2101736 bytes Variable Size 335547928 bytes Database Buffers 729808896 bytes Redo Buffers 6283264 bytes ORA-00201: control file version 10.2.0.3.0 incompatible with ORACLE version 10.2.0.1.0 ORA-00202: control file: '/u01/app/oracle/oradata/jytest/control01.ctl'
這也就證實從oracle 10g開始,compatible參數只能增大,不能縮小。
總結:
1.跨小版本執行跨平臺與字節序的表空間傳輸時,源數據庫的compatible參數必須小於或等於目標數據庫的compatible參數
2.當源數據庫的compatible參數大於目標數據庫的compatible參數時,要執行跨平臺與字節序的表空間傳輸只有將目標數據庫升級爲與源數據庫相同的版本號且compatible參數要大於或等於源數據庫的compatible參數。
3.從oracle 10g開始,compatible參數只能增大,不能縮小。
將Linux平臺上的源數據庫中的tspitr與test表空間傳輸到AIX平臺上。並在源主機上使用目錄/u02/transport來存儲被轉換的數據文件。操做步驟以下:
1.將要被傳輸的表空間tspitr與test設置爲只讀
SQL> alter tablespace tspitr read only; Tablespace altered. SQL> alter tablespace test read only; Tablespace altered.
2.檢查源平臺與目標平臺信息支不支持傳輸操做
數據庫所支持的平臺信息:
SQL> select platform_name,endian_format from v$transportable_platform; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- Solaris[tm] OE (32-bit) Big Solaris[tm] OE (64-bit) Big Microsoft Windows IA (32-bit) Little Linux IA (32-bit) Little AIX-Based Systems (64-bit) Big HP-UX (64-bit) Big HP Tru64 UNIX Little HP-UX IA (64-bit) Big Linux IA (64-bit) Little HP Open VMS Little Microsoft Windows IA (64-bit) Little IBM zSeries Based Linux Big Linux x86 64-bit Little Apple Mac OS Big Microsoft Windows x86 64-bit Little Solaris Operating System (x86) Little IBM Power Based Linux Big Solaris Operating System (x86-64) Little HP IA Open VMS Little
源平臺:
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT ----------------------------------------------------------------------------------------------------- -------------- Linux 64-bit for AMD Little
目標平臺
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- AIX-Based Systems (64-bit) Big
3.確認要被傳輸的表空間是不是自包含表空間(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
若是沒有行選擇,表示該表空間只包含表數據,能夠傳輸。
4.記錄表空間傳輸前表tspitr與test中的記錄:
SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
5.使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.
[oracle@oracle11g ~]export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' [oracle@oracle11g ~]rman target/ Recovery Manager: Release 10.2.0.5.0 - Production on Mon Mar 30 10:35:41 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: TEST (DBID=2168949517) RMAN> convert tablespace "TSPITR","TEST" 2> to platform 'AIX-Based Systems (64-bit)' 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 10:37:27 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=141 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/test/tspitr01.dbf converted datafile=/u02/transport/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/test/test01.dbf converted datafile=/u02/transport/data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 Finished backup at 2015-03-30 10:37:45 [oracle@oracle11g transport]$ ls -lrt total 112776 -rw-r----- 1 oracle oinstall 104865792 Mar 30 10:37 data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 -rw-r----- 1 oracle oinstall 10493952 Mar 30 10:37 data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo
6.使用導出工具建立傳輸表空間元數據dump文件
SQL> create or replace directory test_dump as '/u02/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [oracle@oracle11g dump_test]$ expdp \'sys/zzh_2046@test as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.5.0 - Production on Monday, 30 March, 2015 10:57: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": "sys/********@test AS SYSDBA" directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 10:57:55 [oracle@oracle11g dump_test]ls -lrt -rw-r----- 1 oracle oinstall 960 Mar 30 15:23 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 15:23 tspitr_test.dmp
7.將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中
ftp> put data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 200 PORT command successful. 150 Opening data connection for data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v 8. 226 Transfer complete. ftp: 發送 104865792 字節,用時 8.86秒 11839.88千字節/秒。 ftp> put data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo 200 PORT command successful. 150 Opening data connection for data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo. 226 Transfer complete. ftp: 發送 10493952 字節,用時 0.90秒 11659.95千字節/秒。 ftp> put tspitr_test.dmp 200 PORT command successful. 150 Opening data connection for tspitr_test.dmp. 226 Transfer complete. [IBMP740-1:oracle:/yb_oradata]$ls -lrt -rwxrwxrwx 1 oracle dba 104865792 Mar 30 12:42 data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 -rwxrwxrwx 1 oracle dba 10493952 Mar 30 12:42 data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo -rwxrwxrwx 1 oracle dba 98304 Mar 30 12:42 tspitr_test.dmp
8.將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [IBMP740-1:oracle]$impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo,/yb_oradata/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 11:45:48 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-TEST_I-2168949517_TS-TEST_FNO-7_3bq349vo,/yb_oradata/transport/data_D-TEST_I-2168949517_TS-TSPITR_FNO-6_3aq349v8 Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK ORA-39123: Data Pump transportable tablespace job aborted ORA-00721: changes by release 10.2.0.5.0 cannot be used by release 10.2.0.3.0 Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" stopped due to fatal error at 11:45:53
出錯緣由是由於源數據庫的compatible=10.2.0.5.0,目標數據庫的compatible=10.2.0.3.0這裏在導出使用version=10.2.0.3.0導出元數據後再執行導出也是一樣會報這個錯誤,由於這裏不是邏輯導出,而是傳輸表空間,因此version參數不起做用。因此想修改源數據庫的compatible參數爲10.2.0.3.0,但在10g之後,compatible參數只能增大不能減小。
SQL> show parameter compatible
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
compatible string 10.2.0.5.0
SQL> alter system set compatible='10.2.0.3.0' scope=spfile;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1272600 bytes
Variable Size 109053160 bytes
Database Buffers 54525952 bytes
Redo Buffers 2920448 bytes
ORA-00201: control file version 10.2.0.5.0 incompatible with ORACLE version
10.2.0.3.0
ORA-00202: control file: '/u01/app/oracle/oradata/test/control01.ctl'
在將源數據庫的compatible參數修改成10.2.0.3.0後沒法啓動數據庫。
這裏是從10.2.0.5(源數據庫的compatible參數爲10.2.0.5.0)向10.2.0.4(這裏目標數據庫中的compatible參數卻爲10.2.0.3.0,不是10.2.0.4.0)跨平臺傳輸表空間不會成功,也就是從高版本向低版本傳輸表空間不能成功。但從低版本向高版本傳輸表空間是能夠成功,例以下面的示例:
咱們要將Linux平臺上的源數據庫中的tspitr與test表空間傳輸到AIX平臺上。並在源主機上使用目錄/u02/transport來存儲被轉換的數據文件。操做步驟以下:
1.將要被傳輸的表空間tspitr與test設置爲只讀
SQL> alter tablespace tspitr read only; Tablespace altered. SQL> alter tablespace test read only; Tablespace altered.
2.檢查源平臺與目標平臺信息支不支持傳輸操做
數據庫所支持的平臺信息:
SQL> select platform_name,endian_format from v$transportable_platform; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- Solaris[tm] OE (32-bit) Big Solaris[tm] OE (64-bit) Big Microsoft Windows IA (32-bit) Little Linux IA (32-bit) Little AIX-Based Systems (64-bit) Big HP-UX (64-bit) Big HP Tru64 UNIX Little HP-UX IA (64-bit) Big Linux IA (64-bit) Little HP Open VMS Little Microsoft Windows IA (64-bit) Little IBM zSeries Based Linux Big Linux x86 64-bit Little Apple Mac OS Big Microsoft Windows x86 64-bit Little Solaris Operating System (x86) Little IBM Power Based Linux Big Solaris Operating System (x86-64) Little HP IA Open VMS Little
源平臺:
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT ----------------------------------------------------------------------------------------------------- -------------- Linux 64-bit for AMD Little
目標平臺
SQL> select d.platform_name,endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name ; PLATFORM_NAME ENDIAN_FORMAT -------------------------------------------------------------------------------- -------------- AIX-Based Systems (64-bit) Big
3.確認要被傳輸的表空間是不是自包含表空間(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
若是沒有行選擇,表示該表空間只包含表數據,能夠傳輸。
4.記錄表空間傳輸前表tspitr與test中的記錄:
SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
5.使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.
[oracle@weblogic28 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' [oracle@weblogic28 ~]$ rman target/ Recovery Manager: Release 10.2.0.1.0 - Production on Mon Mar 30 15:16:38 2015 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: JYTEST (DBID=3911337604) RMAN> convert tablespace "TSPITR","TEST" to platform 'AIX-Based Systems (64-bit)' 2> 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 15:17:09 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=134 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/jytest/tspitr01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/jytest/test01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 Finished backup at 2015-03-30 15:17:12 [root@weblogic28 transport]# ls -lrt total 102528 -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn
6.使用導出工具建立傳輸表空間元數據dump文件
SQL> create or replace directory test_dump as '/u02/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [oracle@weblogic28 ~]$ expdp \'sys/system as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.1.0 - 64bit Production on Monday, 30 March, 2015 15:23:19 Copyright (c) 2003, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": 'sys/******** AS SYSDBA' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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: /u02/transport/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 15:23:29 [root@weblogic28 transport]# ls -lrt total 102624 -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm -rw-r----- 1 oracle oinstall 52436992 Mar 30 15:17 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn -rw-r----- 1 oracle oinstall 960 Mar 30 15:23 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 15:23 tspitr_test.dmp
7.將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中
ftp> get data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4497 seconds (1.139e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm remote: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm ftp> get data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4518 seconds (1.133e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn remote: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn ftp> get tspitr_test.dmp 200 PORT command successful. 150 Opening BINARY mode data connection for tspitr_test.dmp (90112 bytes). 226 Transfer complete. 90112 bytes received in 0.001825 seconds (4.822e+04 Kbytes/s) local: tspitr_test.dmp remote: tspitr_test.dmp [IBMP740-1:oracle:/yb_oradata/transport]$ls -lrt total 205008 -rwxrwxrwx 1 oracle dba 52436992 Mar 30 15:06 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm -rwxrwxrwx 1 oracle dba 52436992 Mar 30 15:06 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn -rwxrwxrwx 1 oracle dba 90112 Mar 30 15:07 tspitr_test.dmp
8.將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. IBMP740-1:oracle:/yb_oradata/transport]impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 15:09:38 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_01q34qbm,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_02q34qbn Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 15:09:42 [IBMP740-1:oracle:/yb_oradata/transport]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 16:36:19 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 10.2.0.3.0 SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
能夠看到,從10.2.0.1(compatible=10.2.0.1.0)向10.2.0.4(compatible=10.2.0.3.0)跨平臺和字節序傳輸表空間是能夠執行成功。
爲了從10.2.0.5向10.2.0.4(compatible=10.2.0.3.0)跨平臺傳輸表空間,我這裏測試一下將10.2.0.1源數據庫升級到 10.2.0.5但compatible設置爲10.2.0.1.0或小於目標數據庫的compatible=10.2.0.3.0來進行測試。
[oracle@weblogic28 ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.5.0 - Production on Mon Mar 30 19:17:59 2015 Copyright (c) 1982, 2010, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select version from v$instance; VERSION ----------------- 10.2.0.5.0 SQL> show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 10.2.0.1.0
將源數據庫從10.2.0.1升級到10.2.0.5後compatible參數仍是爲10.2.0.1.0
使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.
[oracle@weblogic28 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' [oracle@weblogic28 ~]$ rman target/ Recovery Manager: Release 10.2.0.5.0 - Production on Mon Mar 30 19:21:39 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: JYTEST (DBID=3911337604) RMAN> convert tablespace "TSPITR","TEST" 2> to platform 'AIX-Based Systems (64-bit)' 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 19:22:01 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=148 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/jytest/tspitr01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/jytest/test01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03 Finished backup at 2015-03-30 19:22:08
使用導出工具建立傳輸表空間元數據dump文件
SQL> create or replace directory test_dump as '/u02/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [oracle@weblogic28 ~]$ expdp \'sys/system as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.5.0 - 64bit Production on Monday, 30 March, 2015 19:23:47 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": "sys/******** AS SYSDBA" directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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: /u02/transport/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 19:24:00 [oracle@weblogic28 transport]$ ls -lrt total 102624 -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:22 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:22 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt -rw-r--r-- 1 oracle oinstall 986 Mar 30 19:24 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 19:24 tspitr_test.dmp
將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中
ftp> get data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4462 seconds (1.148e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt remote: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt ftp> get data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4458 seconds (1.149e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq remote: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq ftp> get tspitr_test.dmp 200 PORT command successful. 150 Opening BINARY mode data connection for tspitr_test.dmp (90112 bytes). 226 Transfer complete. 90112 bytes received in 0.00183 seconds (4.809e+04 Kbytes/s) local: tspitr_test.dmp remote: tspitr_test.dmp [IBMP740-1:oracle:/yb_oradata/transport]$rm tspitr_test.log [IBMP740-1:oracle:/yb_oradata/transport]$ls -lrt total 205008 -rw-r--r-- 1 oracle dba 52436992 Mar 30 19:08 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt -rw-r--r-- 1 oracle dba 52436992 Mar 30 19:08 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq -rw-r--r-- 1 oracle dba 90112 Mar 30 19:08 tspitr_test.dmp
將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [IBMP740-1:oracle:/yb_oradata/transport]$impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 19:12:27 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_04q358mt,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_03q358mq Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 19:12:33 SQL> select count(*) from tspitr.tspitr; COUNT(*) ---------- 50315 SQL> select count(*) from test.test; COUNT(*) ---------- 50316
能夠看到執行成功。雖然源數據庫是10.2.0.5,但其compatible爲10.2.0.1.0,而目標數據庫是10.2.0.4,其compatible參數爲10.2.0.3.0,傳輸表空間是能成功執行的。
下面將源數據庫的compatible修改成10.2.0.3.0(與目標數據庫的compatible同樣)
[oracle@weblogic28 dbs]$ vi initjytest.ora 省.... *.compatible='10.2.0.3.0' SQL> startup pfile='/u01/app/oracle/product/10.2.0/db/dbs/initjytest.ora'; ORACLE instance started. Total System Global Area 1073741824 bytes Fixed Size 2101736 bytes Variable Size 335547928 bytes Database Buffers 729808896 bytes Redo Buffers 6283264 bytes Database mounted. Database opened. SQL> show parameter compatible NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ compatible string 10.2.0.3.0
使用RMAN將源數據庫中的表空間tspitr,test轉換爲目標平臺字節序格式,使用format參數來控制被轉換後數據文件的文件名和存儲目錄.
[oracle@weblogic28 dbs]$ rman target/ Recovery Manager: Release 10.2.0.5.0 - Production on Mon Mar 30 19:47:07 2015 Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: JYTEST (DBID=3911337604) RMAN> convert tablespace "TSPITR","TEST" 2> to platform 'AIX-Based Systems (64-bit)' 3> format ='/u02/transport/%U'; Starting backup at 2015-03-30 19:47:28 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=141 devtype=DISK channel ORA_DISK_1: starting datafile conversion input datafile fno=00006 name=/u01/app/oracle/oradata/jytest/tspitr01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 channel ORA_DISK_1: starting datafile conversion input datafile fno=00007 name=/u01/app/oracle/oradata/jytest/test01.dbf converted datafile=/u02/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01 Finished backup at 2015-03-30 19:47:31
使用導出工具建立傳輸表空間元數據dump文件
[oracle@weblogic28 dbs]$ expdp \'sys/system as sysdba\' directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST Export: Release 10.2.0.5.0 - 64bit Production on Monday, 30 March, 2015 19:48:36 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": "sys/******** AS SYSDBA" directory=test_dump dumpfile=tspitr_test.dmp logfile=tspitr_test.log transport_tablespaces=TSPITR,TEST 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: /u02/transport/tspitr_test.dmp Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 19:48:50 [oracle@weblogic28 transport]$ ls -lrt total 102624 -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:47 data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h -rw-r----- 1 oracle oinstall 52436992 Mar 30 19:47 data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i -rw-r--r-- 1 oracle oinstall 986 Mar 30 19:48 tspitr_test.log -rw-r----- 1 oracle oinstall 90112 Mar 30 19:48 tspitr_test.dmp
將轉換後存儲在/u02/transport目錄中的數據文件與導出的元數據文件tspitr_test.dmp傳輸到目標主機的目錄/yb_oradata/transport中
ftp> get data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4461 seconds (1.148e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h remote: data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h ftp> get data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i 200 PORT command successful. 150 Opening BINARY mode data connection for data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i (52436992 bytes). 226 Transfer complete. 52436992 bytes received in 0.4481 seconds (1.143e+05 Kbytes/s) local: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i remote: data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i ftp> get tspitr_test.dmp 200 PORT command successful. 150 Opening BINARY mode data connection for tspitr_test.dmp (90112 bytes). 226 Transfer complete. 90112 bytes received in 0.001821 seconds (4.833e+04 Kbytes/s) local: tspitr_test.dmp remote: tspitr_test.dmp
將要被傳輸的表空間附加到目標數據庫中
[IBMP740-1:oracle:/yb_oradata]$sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Mar 30 11:31:47 2015 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 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 or replace directory test_dump as '/yb_oradata/transport'; Directory created. SQL> grant read,write on directory test_dump to public; Grant succeeded. [IBMP740-1:oracle:/yb_oradata/transport]$impdp system/system directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i Import: Release 10.2.0.4.0 - 64bit Production on Monday, 30 March, 2015 19:32:30 Copyright (c) 2003, 2007, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01": system/******** directory=test_dump dumpfile=tspitr_test.dmp transport_datafiles=/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TSPITR_FNO-6_05q35a6h,/yb_oradata/transport/data_D-JYTEST_I-3911337604_TS-TEST_FNO-7_06q35a6i Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 19:32:32
能夠看到,將源數據庫10.2.0.5的compatible設置爲10.2.0.3.0與目標數據庫10.2.0.4的compatible同樣,執行傳輸表空間是能夠執行成功的。
以前使用pfile參數文件參源數據庫的compatible參數從10.2.0.1.0修改成10.2.0.3.0了,如今將其修改成10.2.0.1.0,並從新使用pfile文件啓動源數據庫會報錯。
[oracle@weblogic28 dbs]$ vi initjytest.ora 省.... *.compatible='10.2.0.1.0' SQL> startup pfile='/u01/app/oracle/product/10.2.0/db/dbs/initjytest.ora'; ORACLE instance started. Total System Global Area 1073741824 bytes Fixed Size 2101736 bytes Variable Size 335547928 bytes Database Buffers 729808896 bytes Redo Buffers 6283264 bytes ORA-00201: control file version 10.2.0.3.0 incompatible with ORACLE version 10.2.0.1.0 ORA-00202: control file: '/u01/app/oracle/oradata/jytest/control01.ctl'
這也就證實從oracle 10g開始,compatible參數只能增大,不能縮小。
總結: 1.跨小版本執行跨平臺與字節序的表空間傳輸時,源數據庫的compatible參數必須小於或等於目標數據庫的compatible參數 2.當源數據庫的compatible參數大於目標數據庫的compatible參數時,要執行跨平臺與字節序的表空間傳輸只有將目標數據庫升級爲與源數據庫相同的版本號且compatible參數要大於或等於源數據庫的compatible參數。 3.從oracle 10g開始,compatible參數只能增大,不能縮小。