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

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

时间:2023-05-22 14:32:29浏览次数:32  
标签:datafile set HP Soalris t1 Sparc xtts backup channel


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)


$ rman target /       


                 


         Recovery Manager: Release 11.2.0.3.0 - Production on Thu May 4 16:20:45 2017       


                 


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


                 


         connected to target database: CQDB (DBID=1910815733)       


                 


         RMAN> run {       


         set until scn=14528565277766;       


         allocate channel t1 type disk ;       


         backup incremental from scn 14528539218186 tablespace 'XTTS'  format '/tmp/xtts_incr1.bak';       


         release channel t1;       


         }2> 3> 4> 5> 6>        


                 


         executing command: SET until clause       


                 


         using target database control file instead of recovery catalog       


         allocated channel: t1       


         channel t1: SID=3692 instance=cqdb3 device type=DISK       


                 


         Starting backup at 04-MAY-2017 16:21:06       


                 


         backup will be obsolete on date 11-MAY-2017 16:21:09       


         archived logs will not be kept or backed up       


         channel t1: starting full datafile backup set       


         channel t1: specifying datafile(s) in backup set       


         input datafile file number=00941 name=+DATA/cqdb/datafile/xtts.1277.943107855       


         channel t1: starting piece 1 at 04-MAY-2017 16:21:10       


         channel t1: finished piece 1 at 04-MAY-2017 16:21:17       


         piece handle=/tmp/xtts_incr1.bak tag=TAG20170504T162108 comment=NONE       


         channel t1: backup set complete, elapsed time: 00:00:07       


                 


         backup will be obsolete on date 11-MAY-2017 16:21:18       


         archived logs will not be kept or backed up       


         channel t1: starting full datafile backup set       


         channel t1: specifying datafile(s) in backup set       


         including current control file in backup set       


         channel t1: starting piece 1 at 04-MAY-2017 16:21:26       


         released channel: t1


 

 

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

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

DECLARE       


                 handle    varchar2(512);       


                 comment   varchar2(80);       


                 media     varchar2(80);       


                 concur    boolean;       


                 recid     number;       


                 stamp     number;       


                 pltfrmfr number;       


                 devtype   VARCHAR2(512);       


         BEGIN       


                 BEGIN       


                 sys.dbms_backup_restore.restoreCancel(TRUE);       


                 devtype := sys.dbms_backup_restore.deviceAllocate;       


                 sys.dbms_backup_restore.backupBackupPiece(bpname => '/tmp/xtts_incr1.bak',fname => '/tmp/xtts_conv_incr1.bak',handle => handle,media=> media,comment=> comment, concur=> concur,recid=> recid,stamp => stamp, check_logical => FALSE,copyno=> 1, deffmt=> 0, copy_recid=> 0,copy_stamp => 0,npieces=> 1,dest=> 0,pltfrmfr=> 4);       


                 END;       


         END;       


         /


 

 

执行结果如下:

SQL> start xtts_conv1.sql;       


                 


         PL/SQL procedure successfully completed.


 

 

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

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

我这里先进行了:

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

SQL> commit;

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

set serveroutput on;       


         DECLARE       


                 outhandle varchar2(512) ;       


                 outtag varchar2(30) ;       


                 done boolean ;       


                 failover boolean ;       


                 devtype VARCHAR2(512);       


         BEGIN       


                 DBMS_OUTPUT.put_line('Entering RollForward');       


                 -- Now the rolling forward.       


                 devtype := sys.dbms_backup_restore.deviceAllocate;       


                 sys.dbms_backup_restore.applySetDatafile(check_logical => FALSE, cleanup => FALSE) ;       


                 DBMS_OUTPUT.put_line('After applySetDataFile');       


         sys.dbms_backup_restore.applyDatafileTo(dfnumber =>  941 ,toname => '+DATA/test/datafile/xtts_new.dbf',fuzziness_hint => 0, max_corrupt => 0, islevel0 => 0,recid => 0, stamp => 0);       


                 DBMS_OUTPUT.put_line('Done: applyDataFileTo');       


                 DBMS_OUTPUT.put_line('Done: applyDataFileTo');       


                 -- Restore Set Piece       


                 sys.dbms_backup_restore.restoreSetPiece(handle => '/tmp/xtts_conv_incr1.bak',tag => null, fromdisk => true, recid => 0, stamp => 0) ;       


                 


                 DBMS_OUTPUT.put_line('Done: RestoreSetPiece');       


                 


                 -- Restore Backup Piece       


                 sys.dbms_backup_restore.restoreBackupPiece(done => done, params => null, outhandle => outhandle,outtag => outtag, failover => failover);       


                 DBMS_OUTPUT.put_line('Done: RestoreBackupPiece');       


                 sys.dbms_backup_restore.restoreCancel(TRUE);       


                 sys.dbms_backup_restore.deviceDeallocate;       


                 END;       


                 /


 

 

执行结果如下:

SQL> @apply_incr1.sql       


         Entering RollForward       


         After applySetDataFile       


         Done: applyDataFileTo       


         Done: applyDataFileTo       


         Done: RestoreSetPiece       


         Done: RestoreBackupPiece       


                 


         PL/SQL procedure successfully completed.


 

 

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

SQL> alter tablespace xtts  read only ;

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

run {       


         allocate channel t1 type disk ;       


         backup incremental from scn 14528565277766 tablespace 'XTTS'  format '/tmp/xtts_incr2.bak';       


         release channel t1;       


         }


 

 

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

步骤略(同上)

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

步骤略(同上)

11、源端导出元数据

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

transport_tablespace=y       


         tablespaces=('XTTS')       


         file=xtts_tab.dmp       


         log=xtts_tab.log


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

<pre class="brush:plain">$ 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.</pre>



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.


13、检查数据

-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 count(1) from test0504;       


                 


                 COUNT(1)       


         ----------       


                 100       


                 


         SQL> select PLATFORM_NAME from v$database;       


                 


         PLATFORM_NAME       


         --------------------------------------------------------------------------------       


         Solaris[tm] OE (64-bit)       


                 


         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表空间已经被迁移过来了,并且增量的数据也已经同步了。

所以我想表达的是,所有的跨平台迁移,其实都可以利用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状态下执行脚本即可。

标签:datafile,set,HP,Soalris,t1,Sparc,xtts,backup,channel
From: https://blog.51cto.com/databasenotes/6324016

相关文章

  • 【PHP兴趣部落-05】html table(表格)
    一、简介:表格由<table>标签来定义。每个表格均有若干行(由<tr>标签定义),每行被分割为若干单元格(由<td>标签定义)。字母td指表格数据(tabledata),即数据单元格的内容。数据单元格可以包含文本、图片、列表、段落、表单、水平线、表格等等。二、代码<!DOCTYPEhtml><html......
  • 【PHP兴趣部落-09】递归转义
    一、定义addslashes()函数返回在预定义字符之前添加反斜杠的字符串。预定义字符是:单引号(’)双引号(”)反斜杠(\)NULL注释:默认地,PHP对所有的GET、POST和COOKIE数据自动运行addslashes()。所以您不应对已转义过的字符串使用addslashes(),因为这样会导致双层转义。遇到这种情况时可......
  • 【PHP兴趣部落-08】PHP中时区设置的三种方法(timezone)
    一、三种方法php中时区默认是格林尼治时间,和中国时差八个小时。现在根据需要将时间设置为中国时间,下面整理了三种方法。方法1:最好的方法在php.ini里加上找到date.timezone项,设置date.timezone=“Asia/Shanghai”,重启环境就ok了。方法2:在需要用到这些时间函数的时候,在页面添......
  • 【PHP兴趣部落-04】html 表单中常用元素
    一、简介html表单中常用的一些元素:比如按钮,输入框、单选框、复选框等控件元素。表单标签:<form>元素标签:<inputtype=”类型”name=”控件名”value=”值”>三、代码<html><head><title>html基本元素学习</title></head><!--表单--><formaction="ok.html"met......
  • PhpStorm-中文汉化版设置教程
    原文地址:https://www.ngxcode.com/archives/607.html前言相信不少开发PHP的同学,对PhpStorm编辑器都不陌生,PhpStorm是JetBrains公司开发的一款商业的PHP集成开发工具,旨在提高用户效率,可深刻理解用户的编码,提供智能代码补全,快速导航以及即时错误检查。但PhpStorm默认是英文......
  • ctfshow php特性
    web111源代码highlight_file(__FILE__);error_reporting(0);include("flag.php");functiongetFlag(&$v1,&$v2){eval("$$v1=&$$v2;");//这里是一个赋值语句把v2的值复制下面通过get获得的$$v1值var_dump($$v1);//打印$$v1的值}if(isset($_......
  • []复习]cityengine2019/2022导入shp数据生成福田区建筑群
    时间是一把杀猪刀和人工智能比起来我太弱了.很无助.无法给自己升级系统.cityengine2019目前载入那种地区线上数据是行不通了,2022可以整一个邮箱试用一个月.https://www.esri.com/zh-cn/arcgis/products/arcgis-cityengine/trial/professionals我整了一个万能无线邮箱,无法注册,......
  • php+phpstorm+xdebug配置
    简介原文链接:https://culturesun.site/index.php/archives/675.html因为博客是php的,所以无奈接触了php开发,虽然之前也学习过php语法。搞开发是离不开debug。最初从网上找到相关教程配置成功了,后来升级php,浏览器崩了搞的debug不行,再配置怎么也不成功,准确的来说,网上的辣鸡贴子太......
  • 宝塔面板中安装php8以上环境,提示: configure: error: iconv does not support errno
    问题:宝塔面板中安装php8编译时提示configure:error:iconvdoesnotsupporterrno#下面这些是配置yum源和epel源,阿里云ecs在centos8测试成功wgethttp://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo-O/etc/yum.repos.d/Centos-vault-8.5.2111.repo&&......
  • php 操作数组 (合并,拆分,追加,查找,删除等)
    1.合并数组array_merge()函数将数组合并到一起,返回一个联合的数组。所得到的数组以第一个输入数组参数开始,按后面数组参数出现的顺序依次迫加。其形式为:Php代码1.arrayarray_merge(array这个函数将一个或多个数组的单元合并起来,一个数组中的值附加在前一个数组......