rman convert可实现不同字节顺序endian_format的表空间转换,用于不同字节顺序endian_format的跨平台表空间传输.
os: centos 6.6
db version:11.2.0.4.0
以下测试:
[oracle@ct6605 ~]$ sqlplus / as sysdba
##列出支持转换的平台及字节顺序
SQL> select * from v$transportable_platform;
/*
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
1 Solaris[tm] OE (32-bit) Big
2 Solaris[tm] OE (64-bit) Big
7 Microsoft Windows IA (32-bit) Little
10 Linux IA (32-bit) Little
6 AIX-Based Systems (64-bit) Big
3 HP-UX (64-bit) Big
5 HP Tru64 UNIX Little
4 HP-UX IA (64-bit) Big
11 Linux IA (64-bit) Little
15 HP Open VMS Little
8 Microsoft Windows IA (64-bit) Little
9 IBM zSeries Based Linux Big
13 Linux x86 64-bit Little
16 Apple Mac OS Big
12 Microsoft Windows x86 64-bit Little
17 Solaris Operating System (x86) Little
18 IBM Power Based Linux Big
19 HP IA Open VMS Little
20 Solaris Operating System (x86-64) Little
21 Apple Mac OS (x86-64) Little
*/
##convert tablespace
#convert tablespace必须在源数据库执行
#转换只是跨平台不同endian_format传输的一部分,其它tts的步骤这里省略
[oracle@ct6605 ~]$ sqlplus / as sysdba
#将要转换的表空间只读
SQL> alter tablespace test read only;
#转换为'AIX-Based Systems (64-bit)'平台使用的表空间
[oracle@ct6605 ct66]$ rman target /
RMAN> convert tablespace 'TEST'
to platform 'AIX-Based Systems (64-bit)'
db_file_name_convert '/u02/oradata/ct66','/home/oracle';
##convert datafile
#convert datafile必须在目标库执行
#配合上rman transport在源库生成导入元数据和数据文件,convert datafile在目标库执行,这样可以免去源库表空间read only
[oracle@ct6605 ct66]$ rman target /
#转换为'Linux x86 64-bit'平台使用的数据文件
RMAN> convert datafile
'/home/oracle/test01.dbf'
to platform 'Linux x86 64-bit'
from platform 'AIX-Based Systems (64-bit)'
db_file_name_convert '/home/oracle','/home/oracle/test';
##convert database#convert database是只支持相同字节顺序endian_format#convert database可在源库也可在目标库执行
#源库和目标库的版本要相同
[oracle@ct6605 ~]$ sqlplus / as sysdba
#启动数据库到read only模式
SQL> shutdown immediate;
SQL> statup open read only;
#使用dbms_tdb.check_db检查是否支持转换
SQL> declare
b_support boolean;
begin
b_support := dbms_tdb.check_db('Linux x86 64-bit', 0);
dbms_output.put_line(case b_support when true then 'support' else
'nonsupport' end);
end;
/
/*
support
*/
#使用dbms_tdb.check_external检查需要手工处理的部分
SQL> declare
b_external boolean;
begin
b_external := dbms_tdb.check_external;
end;
/
/*
The following directories exist in the database:
SYS.HOME_DUMP, SYS.TSPITR_DIROBJ_DPDIR, SYS.XMLDIR, SYS.ORACLE_OCM_CONFIG_DIR2, SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR
*/
[oracle@ct6605 ct66]$ rman target /
#开始转换数据库
#下面是在源库转换的数据库,也可以通过convert database on target platform上目标库上转换.
#在目标库转换,convert database on target platform命令也是在源库执行,用来产生转换脚本.#convert database on target platform命令要加上convert script参数生成转换文件脚本.
RMAN> convert database new database ct66new
transport script '/home/oracle/initdb.sql'
to platform 'Linux x86 64-bit'
db_file_name_convert '/u02/oradata/ct66','/home/oracle';
/*
Starting conversion at source at 08-JAN-16
using channel ORA_DISK_1
Directory SYS.HOME_DUMP found in the database
Directory SYS.TSPITR_DIROBJ_DPDIR found in the database
Directory SYS.XMLDIR found in the database
Directory SYS.ORACLE_OCM_CONFIG_DIR2 found in the database
Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=/u02/oradata/ct66/system01.dbf
converted datafile=/home/oracle/system01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00002 name=/u02/oradata/ct66/sysaux01.dbf
converted datafile=/home/oracle/sysaux01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=/u02/oradata/ct66/undotbs01.dbf
converted datafile=/home/oracle/undotbs01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00005 name=/u02/oradata/ct66/test01.dbf
converted datafile=/home/oracle/test01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=/u02/oradata/ct66/users01.dbf
converted datafile=/home/oracle/users01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Edit init.ora file /u01/app/oracle/product/11.2.0/db_1/dbs/init_00qqs7jp_1_0.ora. This PFILE will be used to create the database on the target platform
#利用产生的/home/oracle/initdb.sql脚本在目标库执行,并通过utlirp.sql重新编译对象
#/home/oracle/initdb.sql要根据实际的情况做相应的修改,或者手动执行里面的内容
Run SQL script /home/oracle/initdb.sql on the target platform to create database
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 08-JAN-16
*/