XTTS基于rman全量迁移Oracle

Posted IT邦德

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了XTTS基于rman全量迁移Oracle相关的知识,希望对你有一定的参考价值。

xtts 跨平台迁移数据库

建议xtts目录和/rman 备份的路径目录都使用nfs共享


alter system set deferred_segment_creation=false sid=* scope=spfile;

###########################增量临时文件在asm#########xtt.properties ##########################
tablespaces=SPROD_TBS,IDX_TBS
platformid=13
dfcopydir=/xttrman/full 本地全量备份数据的路径
backupformat=/xttrman/incr 本地增量备份数据的路径
stageondest=/xttrman/full 目标端所需要恢复数据的路径,后续生成的增量也要拷贝到这里
storageondest=+DATA/prod/datafile 目标端数据文件路径 -c 的时候放的位置
backupondest=+DATA/prod/datafile 目标端增量文件的临时路径,做完增量后会自动删除,如果放asm需要设置asm_home和asm_sid
asm_home=/oracle/app/grid/product/11.2.0/grid
asm_sid=+ASM
parallel=2
rollparallel=2
getfileparallel=2
#############################建议使用这种方式,增量临时文件在文件系统######xtt.properties #######################
tablespaces=SPROD_TBS,IDX_TBS
platformid=13
dfcopydir=/xttrman/full
backupformat=/xttrman/incr
stageondest=/xttrman/full
storageondest=+DATA/prod/datafile
backupondest=/xttrman/rec
#asm_home=/oracle/app/grid/product/11.2.0/grid
#asm_sid=+ASM
parallel=2
rollparallel=2
getfileparallel=2
###########################################################################################


源端全量备份脚本
cat full_backup.sh 
export TMPDIR=/oracle/soft/xttconvert
perl xttdriver.pl -p

源端执行全量备份
sh full_backup.sh

生成文件
[oracle@localhost xttconvert]$ cat xttplan.txt 
SPROD_TBS::::967892
5
6
IDX_TBS::::967892
7

[oracle@localhost xttconvert]$ cat xttplan.txt 
SPROD_TBS::::967892
5
6
IDX_TBS::::967892
7
[oracle@localhost xttconvert]$ cat rmanconvert.cmd
host echo ts::SPROD_TBS; 
convert from platform Linux x86 64-bit 
datafile 
/xttrman/full/SPROD_TBS_5.tf 
,/xttrman/full/SPROD_TBS_6.tf 
format +DATA/prod/datafile/%N_%f.dbf 
parallelism 2; 
host echo ts::IDX_TBS; 
convert from platform Linux x86 64-bit 
datafile 
/xttrman/full/IDX_TBS_7.tf 
format +DATA/prod/datafile/%N_%f.dbf 
parallelism 2;

目标端,执行恢复转换
vi convert.sh
export XTTDEBUG=1
export TMPDIR=/oracle/soft/xttconvert
perl xttdriver.pl -c

sh convert.sh

vi do_incr.sh
export TMPDIR=/oracle/soft/xttconvert
perl xttdriver.pl -i


源端增量备份
sh do_incr.sh

[oracle@localhost xttconvert]$ cat xttplan.txt.new 
SPROD_TBS::::968168
5
6
IDX_TBS::::968196
7
[oracle@localhost xttconvert]$ cat tsbkupmap.txt
IDX_TBS::7:::1=07u31cir_1_1
SPROD_TBS::5,6:::1=06u31ciq_1_1


注意每次做完增量 需要将增量的数据文件拷贝到全量备份的目录下,恢复完删除/xttrman/incr/*
cp /xttrman/incr/* /xttrman/full/

目标端增量恢复
vi restore_incr.sh
export TMPDIR=/oracle/soft/xttconvert
perl xttdriver.pl -r


注意如果增量恢复文件放在asm可能会出现以下错误,可以忽略,这个是xtts无法自动删除asm的临时文件
Cant locate strict.pm in @INC (@INC contains: /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0 /oracle/app/grid/product/11.2.0/grid/lib /oracle/app/grid/product/11.2.0/grid/lib/asmcmd /oracle/app/grid/product/11.2.0/grid/rdbms/lib/asmcmd /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl .) at /oracle/app/grid/product/11.2.0/grid/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /oracle/app/grid/product/11.2.0/grid/bin/asmcmdcore line 143.
Cant locate strict.pm in @INC (@INC contains: /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0 /oracle/app/grid/product/11.2.0/grid/lib /oracle/app/grid/product/11.2.0/grid/lib/asmcmd /oracle/app/grid/product/11.2.0/grid/rdbms/lib/asmcmd /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl/5.10.0 /oracle/app/grid/product/11.2.0/grid/perl/lib/site_perl .) at /oracle/app/grid/product/11.2.0/grid/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /oracle/app/grid/product/11.2.0/grid/bin/asmcmdcore line 143.

下次增量要记录当前恢复的scn位置,产生最新 xttplan.txt 文件要不然下次增量还会在全量进行备份
perl xttdriver.pl -s

后续增量循环以下三步骤
sh do_incr.sh
sh restore_incr.sh
perl xttdriver.pl -s


最后一次增量,表空间设置为只读模式
SQL> alter tablespace SPROD_TBS read only;

Tablespace altered.

SQL> alter tablespace IDX_TBS read only;

Tablespace altered.

最后一次恢复
sh do_incr.sh 
sh restore_incr.sh


导入元数据,建议不要导入统计信息,目标库直接收集
create or replace directory xtts_dir as /oracle/soft/
create database link ttslink connect to system identified by "oracle" USING sprod;

ASMCMD> ls -al
WARNING:option a is deprecated for ls
please use absolutepath

Type Redund Striped Time Sys Name
DATAFILE UNPROT COARSE JUN 01 21:00:00 Y +DATA/PROD/DATAFILE/idx_tbs_7.dbf => IDX_TBS.274.1009834557
DATAFILE UNPROT COARSE JUN 01 21:00:00 Y +DATA/PROD/DATAFILE/sprod_tbs_5.dbf => SPROD_TBS.273.1009834553
DATAFILE UNPROT COARSE JUN 01 21:00:00 Y +DATA/PROD/DATAFILE/sprod_tbs_6.dbf => SPROD_TBS.275.1009834553
DATAFILE UNPROT COARSE JUN 01 21:00:00 Y none => SYSAUX.257.1009808403
DATAFILE UNPROT COARSE JUN 01 21:00:00 Y none => SYSTEM.256.1009808403
DATAFILE UNPROT COARSE JUN 01 21:00:00 Y none => UNDOTBS1.258.1009808403
DATAFILE UNPROT COARSE JUN 01 21:00:00 Y none => USERS.259.1009808403
N idx_tbs_7.dbf => +DATA/PROD/DATAFILE/IDX_TBS.274.1009834557
N sprod_tbs_5.dbf => +DATA/PROD/DATAFILE/SPROD_TBS.273.1009834553
N sprod_tbs_6.dbf => +DATA/PROD/DATAFILE/SPROD_TBS.275.1009834553
ASMCMD>

impdp \/ as sysdba\‘ directory=xtts_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=SPROD_TBS,IDX_TBS exclude=STATISTICS transport_datafiles=+DATA/PROD/DATAFILE/IDX_TBS.275.1009832163,+DATA/PROD/DATAFILE/SPROD_TBS.274.1009832159,+DATA/PROD/DATAFILE/SPROD_TBS.273.1009832159

 

 

ls -al|grep -v *.zip|grep -v .sh|awk -F  print $9|xargs rm -rf

 

以上是关于XTTS基于rman全量迁移Oracle的主要内容,如果未能解决你的问题,请参考以下文章

记录一则xtts测试遇到的诡异现象

XTTS系列之一:U2L迁移解决方案之XTTS的使用

XTTS跨平台迁移impdp导入元数据报ORA-29349

转 TTSAIX平台数据库迁移到Linux--基于RMAN(真实环境)

oracle rman备份与恢复 全量备份、增量备份

使用RMAN迁移数据库到异机