love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客

Phone:18180207355 提供专业Oracle/MySQL/PostgreSQL数据恢复、性能优化、迁移升级、紧急救援等服务

使用XTTS增量进行HP Unix到Soalris Sparc的数据库迁移

自从2015年初进行了xtts增量的U2L迁移测试之后,国内很多人都开始利用这种方案进行数据库跨平台迁移了,基本上都是利用Oracle 封装的perl脚本。其中Oracle MOS文档 11G – Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (文档 ID 1389592.1) 明确提到目标端环境必须是Linux,这里该文档中的一段原话:

The source system may be any platform provided the prerequisites referenced and listed below for both platform and database are met. The destination system must be Linux, either 64-bit Oracle Linux or RedHat Linux, as long as it is a certified version. The typical use case is expected to be migrating data from a big endian platform, such as IBM AIX, HP-UX, or Solaris SPARC, to 64-bit Oracle Linux, such as Oracle Exadata Database Machine running Oracle Linux.

其实这里很容易让人产生误解,这里Oracle并非说不支持其他平台,而是说Oracle 提供的封装perl脚本不支持而已。但是手工进行xtts操作,完全是ok的经过我的测试也是可行,这里是测试从Hp IA到Solaris Sparc的xtts增量迁移方式,供参考。

1、首先在原端创建测试表空间和测试表.

-创建测试表空间

create tablespace xtts datafile ‘+data’ size 100m;

create table test0504 as select * from dba_objects where 1=2;

alter table test504 move tablespace xtts;

2、备份xtts表空间文件,并传输到目标端(Solaris)

略.

3、目标端进行文件格式转换

convert from platform ‘HP-UX IA (64-bit)’ datafile  ‘/tmp/xtts.dbf’ format ‘+DATA/test/datafile/xtts_new.dbf’;

 

 

4、原端进行基于SCN的增量备份(这里由于我是测试表空间,所以未启用Block track  changing)

 

 

5、创建备份集传到目标端并进行备份集格式手工转换(Solaris)

将脚本保存为xtts_conv1.sql并执行,如下是脚本内容:

 

 

执行结果如下:

 

 

6、进行第一次增量应用(Solaris)

说明:为了验证增量数据是否能够同步到目标端,在进行增量备份之前,

我这里先进行了:

SQL > insert into test0504 select * fro dba_objects where rownm < 101;

SQL> commit;

将如下脚本保存为apply_incr1.sql,并执行:

 

 

执行结果如下:

 

 

7、将原端表空间设置为只读模式

SQL> alter tablespace xtts  read only ;

8、进行最后一次增量备份。

 

 

9、将备份集传输到目标端并进行转换

步骤略(同上)

10、最后一次应用增量备份

步骤略(同上)

11、源端导出元数据

将下列内容保存为exp_xtts.par:

执行如下命令导出xtts表空间上的元数据信息:

$ exp \’/ as sysdba\’ parfile=exp_tab.par

Export: Release 11.2.0.3.0 – Production on Thu May 4 16:46:28 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 – 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Tes
Export done in ZHS16GBK character set and UTF8 NCHAR character set
Note: table data (rows) will not be exported
About to export transportable tablespace metadata…
For tablespace XTTS …
. exporting cluster definitions
. exporting table definitions
. . exporting table TEST0504
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.

12、目标端导入元数据

将下列内容保存为imp_xtts.par:

transport_tablespace=y

TABLESPACES=(‘XTTS’)

file=xtts_tab.dmp

log=xtts_tab.log

datafiles=( ‘+DATA/test/datafile/xtts.dbf’)

执行如下命令导入元数据。

-bash-4.4$ imp \’/ as sysdba\’ parfile=imp_xtts.par

Import: Release 11.2.0.4.0 – Production on Thu May 4 17:47:27 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Tes
Export file created by EXPORT:V11.02.00 via conventional path
About to import transportable tablespace(s) metadata…
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)
export client uses ZHS16GBK character set (possible charset conversion)
export server uses UTF8 NCHAR character set (possible ncharset conversion)
. importing SYS’s objects into SYS
. importing SYS’s objects into SYS
. . importing table “TEST0504”
Import terminated successfully without warnings.

-bash-4.4$ sqlplus “/as sysdba”

SQL*Plus: Release 11.2.0.4.0 Production on Thu May 4 17:47:35 2017

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 – 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select name from v$datafile;

NAME
——————————————————————————–
+DATA/test/datafile/system.657.943109907
+DATA/test/datafile/sysaux.656.943109911
+DATA/test/datafile/undotbs1.654.943109911
+DATA/test/datafile/users.653.943109927
+DATA/test/datafile/xtts_new.dbf

SQL> select PLATFORM_NAME from v$database;

PLATFORM_NAME
——————————————————————————–
Solaris[tm] OE (64-bit)
SQL> select count(1) from test0504;

COUNT(1)
———-
100
SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME STATUS
—————————— ———
SYSTEM ONLINE
SYSAUX ONLINE
UNDOTBS1 ONLINE
TEMP ONLINE
USERS ONLINE
XTTS READ ONLY

所以我想表达的是,所有的跨平台迁移,其实都可以利用XTTS Incremental Backup 功能进行迁移,无论目标端是什么平台。当然,如果字节序相同的情况下,可以直接使用convert database 功能。

补充:

在进行增量应用时,可能会出现如下错误:

ERROR at line 1:
ORA-19583: conversation terminated due to error
ORA-00600: internal error code, arguments: [2130], [941], [100], [4], [], [],
[], [], [], [], [], []
ORA-06512: at “SYS.DBMS_BACKUP_RESTORE”, line 2335
ORA-06512: at line 13

如果遇到这个错误,那么只需要将实例停掉,启动到nomount状态下执行脚本即可。

One Response to “使用XTTS增量进行HP Unix到Soalris Sparc的数据库迁移”

  1. [置顶] 使用XTTS增量进行HP Unix到Soalris Sparc的数据库迁移-IT文库 Says:

    […] 4、原端进行基于SCN的增量备份(这里由于我是测试表空间,所以未启用Block track  changing) ? […]

Leave a Reply

You must be logged in to post a comment.