XTTS+Rman迁移

Phase 1 - Initial Setup phase

1. Install the desired oracle database software (oracle version:11.2.0.4 and later) on the destination system

2. From the source database, check its characterset, sga, processes, hidden parameters .etc for destination instance creation:

SELECT * FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER like '%CHARACTERSET%';

set lines 400;

col name for a30;

col value for a10;

select

x.ksppinm  name,

y.ksppstvl  value,

y.ksppstdf  isdefault,

decode(bitand(y.ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE')  ismod,

decode(bitand(y.ksppstvf,2),2,'TRUE','FALSE')  isadj

from

sys.x$ksppi x,

sys.x$ksppcv y

where

x.inst_id = userenv('Instance') and

y.inst_id = userenv('Instance') and

x.indx = y.indx   and y.ksppstdf='FALSE'  

order by translate(x.ksppinm, ' _', ' ');

3. Use dbca to create database on destination system according to the parameters in step 2 and config the backup and clear archive log scripts

4. Create listener for new instance and copy tnsname.ora, sqlnet.ora from source to destination . In destination system, add a tns item for destination to connect source

CC_XTTS =

(DESCRIPTION =

  (ADDRESS = (PROTOCOL = TCP)(HOST = 10.45.7.128)(PORT = 1521))

  (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = cc)

  )

)

5. Create a database link and a dump directory in the destination database

create public database link ttslink connect to system identified by *** using 'CC_XTTS';

create directory  export as '/oracle12/backup';

6. Config the .profile or .bash_profile with the proper ORACLE_HOME,ORACLE_SID and TMPDIR (TMPDIR is for XTTS temp files and logs) on both source and destination system

eg: export TMPDIR=/home/oracle/tmp

7. From source database , get platform_id for setting xtt.properties  

select platform_id from V$DATABASE;

8. Identify and check tablespaces to be transported, the to-be transported tablespaces must self-contained from the source system:

EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('TBS_TEST,IDX_TEST', TRUE);

select * from TRANSPORT_SET_VIOLATIONS; --no records is expected

9. Check the detailed configuration for the to-be transported user—TEST

select username from dba_users where default_tablespace in('TBS_TEST','IDX_TEST');

SELECT * FROM dba_ts_quotas where username='TEST';

select granted_role from dba_role_privs where grantee='TEST';

select privilege from dba_sys_privs where grantee='TEST';

select USER#,NAME,PASSWORD,CTIME,EXPTIME,LTIME,RESOURCE$,ASTATUS from user$ where NAME='TEST';

10. Create user test with identified by values ‘’ on the destination database

11. 由于 XTTS 最后导入元数据时候不支持临时表,所以需要提前查出系统临时表信息。

select dbms_metadata.get_ddl('TABLE',TABLE_NAME,owner) from dba_tables where  TEMPORARY='Y' and owner=”TEST’;

Phase 2 – Install xttconvert Scripts  

1. Create directories for xtts scripts ,backup files and tmp on both source and destination system

cd /home/oracle

mkdir xtts

mkdir tmp

mkdir backup

2. Unzip rman_xttconvert_v3.zip and Config the xtt.properties on source which is guided file for transport tablespace

 oracle@rac3[/home/oracle/xtts]$grep -v "^#" xtt.properties|grep -v "^$"

tablespaces=TBS_TEST,IDX_TEST   # the tablespaces

platformid=13                   # the platform_id of source system

dfcopydir=/home/oracle/backup    # location of initial datafile copies on source

backupformat=/home/oracle/backup #d incremental backup location on source stageondest=/oracle12/backup    #the datafile copies are placed on destination  

storageondest=/oracle12/oradata/cc_new #the final location of the datafiles in database

backupondest=/oracle12/backup   # incremental backup location on destination

parallel=3

rollparallel=2

getfileparallel=4

3. Scp the xtts scripts to destination  

scp -r xtts/ oracle12@172.16.23.171:/oracle12

Phase 3 Prepare Phase for RMAN Backup Method

1. Make a full backup for source database

cd /home/oracle/xtts

$ORACLE_HOME/perl/bin/perl xttdriver.pl -p

There will be datafile copies under /home/oracle/backup and there are two tmp files generated under /home/oracle/tmp

xttplan.txt

rmanconvert.cmd

2. Transfer Datafile Copies and generated command file to the Destination System

cd /home/oracle/backup

scp TBS_TEST_5.tf IDX_TEST_6.tf oracle12@172.16.23.171:/oracle12/backup

scp /home/oracle/tmp/rmanconvert.cmd oracle12@172.16.23.171:/oracle12/tmp

As transference of datafile copies consumes lots of time, we can create a shared disk between source and destination by mount/umount the shared disk so that we can save time of transferring datafile copies  

3. Convert the Datafile Copies on the Destination System

$ORACLE_HOME/perl/bin/perl xttdriver.pl -c

Phase 4 - Roll Forward Phase

1. Create an Incremental Backup of the Tablespaces on source

cd /home/oracle/xtts

$ORACLE_HOME/perl/bin/perl xttdriver.pl -i

There will be incremental backups under /home/oracle/backup and there are two tmp files generated under /home/oracle/tmp

tsbkupmap.txt

incrbackups.txt

2. Transfer Incremental backups and two generated tmp files to the Destination System(No need if umount/mount can be used

scp `cat /home/oracle/tmp/incrbackups.txt` oracle12@172.16.23.171:/oracle12/backup

scp /home/oracle/tmp/xttplan.txt /home/oracle/tmp/tsbkupmap.txt oracle12@172.16.23.171:/oracle12/tmp

3. Convert the Incremental Backup and apply to the Datafile Copies on the destination

cd /oracle12/xtts

$ORACLE_HOME/perl/bin/perl xttdriver.pl -r

4. Determine the FROM_SCN for the Next Incremental Backup on source

$ORACLE_HOME/perl/bin/perl xttdriver.pl -s

Phase 5 - Transport Phase

0. Repeat Phase 4 if large data gap existed, otherwise, stop the application and make the final incremental backup as below

1. Make the tablespaces read only on source

alter tablespace TBS_TEST read only

alter tablespace IDX_TEST read only;

select status ,tablespace_name from dba_tablespaces ;

2. Create the Final Incremental Backup, Transfer and apply them to datafile copies just like steps 1,2,3 in Phase 4

source:

cd /home/oracle/xtts

$ORACLE_HOME/perl/bin/perl xttdriver.pl -i

scp `cat /home/oracle/tmp/incrbackups.txt` oracle12@172.16.23.171:/oracle12/backup

scp /home/oracle/tmp/xttplan.txt  /home/oracle/tmp/tsbkupmap.txt oracle12@172.16.23.171:/oracle12/tmp

destination:

cd /oracle12/xtts

$ORACLE_HOME/perl/bin/perl xttdriver.pl -r

3. Generate an impdp command for transport tablespaces on destination

$ORACLE_HOME/perl/bin/perl xttdriver.pl -e

There will be a xttplugin.txt under /oracle12/tmp

oracle12@shard22[/oracle12/tmp]$cat xttplugin.txt

impdp directory=<DATA_PUMP_DIR> logfile=<tts_imp.log> \

network_link=<ttslink> transport_full_check=no \

transport_tablespaces=TBS_TEST,IDX_TEST \

transport_datafiles='/oracle12/oradata/cc_new/TBS_TEST_5.dbf','/oracle12/oradata/cc_new/IDX_TEST_6.dbf'

we fill in the command by replace <DATA_PUMP_DIR>,<tts_imp.log>,<ttslink> and add STATISTICS=none

The final impdp command as below and run it on destination

impdp system/**** directory=export logfile=20190905_tts_tbs_idx_test.log \

network_link=ttslink transport_full_check=no STATISTICS=none \

transport_tablespaces=TBS_TEST,IDX_TEST \

transport_datafiles='/oracle12/oradata/cc_new/TBS_TEST_5.dbf','/oracle12/oradata/cc_new/IDX_TEST_6.dbf'

4. Execute an impdp command to import metadata (including procedures, views,dblinks… )

impdp system/*** directory=export logfile=20190905_tts_others_test.log network_link=ttslink CONTENT=metadata_only exclude=statistics SCHEMAS=TEST’

5. Compare several tables from source and destination and run some remaining commands

select count(*) from test.TEST1;

select count(*) from test.TEST2;

select count(*) from test.TEST3;

select count(*) from test.TEST4;

select count(*) from test.TEST5;

 select count(*),object_type from dba_objects where owner='TEST' group by object_type;

select count(*)  from dba_objects where owner='TEST' and status='INVALID';

destination:

select status ,tablespace_name from dba_tablespaces ;

alter user test default tablespace tbs_test  quota unlimited on tbs_test quota unlimited on idx_test;

compile the invalid objects  

@?/rdbms/admin/utlrp.sql

6. Validate the Transported Data

RMAN> validate tablespace TBS_TEST, IDX_TEST check logical;

7. Make tablespaces read write  

alter tablespace TBS_TEST read write;

alter tablespace IDX_TEST read write;

8. Restart the destination database and switch to archivelog mode

Shutdown immediate

Startup mount

Alter database archivelog;

Alter database open;

9. Collecting statistics for TEST schema

exec DBMS_STATS.GATHER_SCHEMA_STATS (ownname=>'TEST',estimate_percent=>1,method_opt=>'FOR ALL INDEXED COLUMNS',degree=>10,cascade=>true,options=>'GATHER AUTO');

Phase 6 Start application and test

If testing all good, we can use the new environment;  

If not, just make the source tablespaces read write and use the old databas  

适用于: Oracle Database Cloud Schema Service - 版本 N/A 和更高版本 Oracle Database Exadata Cloud Machine - 版本 N/A 和更高版本 Oracle Cloud Infrastructure - Database Service - 版本 N/A 和更高版本 Oracle Database Exadata Express Cloud Service - 版本 N/A 和更高版本 Oracle Database Backup Service - 版本 N/A 和更高版本 Linux x86-64 用途 注意: 考虑使用新release的版本V4的过程。 这个版本极大地简化了相关步骤。 请参考文档:V4 Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup Note 2471245.1 本文档覆盖了在 12c 及更高版本上,使用跨平台传输表空间(XTTS)以及 RMAN 增量备份,以最小的应用停机时间,在不 同 endian 格式的系统间迁移数据的步骤。 第一步是从源系统拷贝一份 full backup 到目标系统。之后,使用一系列的增量备份(每一份都比前一份要小),这样在停 机前可以做到目标系统的数据和源系统“几乎”一致。需要停机的步骤只有最终的增量备份及元数据导出/导入。 这个文档描述了在 12c 下使用跨平台增量备份的步骤,关于 11g 下的步骤,请您参考 Note:1389592.1。 跨平台增量备份特性并不能减少 XTTS 的其它步骤花费的时间,比如元数据导出/导入。因此,如果数据库内有很多元数据 (DDL),比如 Oracle E-Business Suite 和其它打包程序,那么跨平台增量备份特性并不能带来很多好处;对于这样的 环境,迁移花的大部分时间是花在处理元数据上,而不是数据文件的转换及传输。 只有被迁移表空间里物理存储的数据库对象才会被拷贝至目标系统;如果要迁移存储在其它表空间的其它类型的对象 (比如存储在 SYSTEM 表空间内的 pl/sql 对象,sequences 等),你可以使用数据泵来拷贝这些对象至目标系统。 注意: 考虑使用新release的版本V4的过程。 这个版本极大地简化了相关步骤。 请参考文档:V4 Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup Note 2471245.1 跨平台增量备份的主要步骤有: 1. 初始化设置 2. 准备阶段(源库数据仍然在线) 1. 备份要传输的表空间(0级备份) 2020/1/5 Document 2102859.1 https://myaccess.oraclevpn.com/+CSCO+1075676763663A2F2F7A6266727A632E68662E62656E7079722E70627A++/epmos/faces/Document… 3/14 2. 把备份及其它必须的文件发送到目标系统 3. 在目标系统恢复数据文件至目标端的 endian 格式 3. 前滚阶段(源库数据仍然在线 – 要重复这个阶段足够多次,使得目标数据文件拷贝和源库越相近越好) 1. 在源库创建增量备份 2. 把增量备份及其它必须的文件发送到目标系统 3. 把增量备份转换成目标系统的 endian 格式并且把增量备份应用至目标数据文件 4. 为下次增量备份确定 next_scn 5. 重复这些步骤直到已经准备好了操作传输表空间 NOTE: 在版本3,如果一个数据文件被加入到一个表空间或者一个新的表空间名字被加入到xtt.properties文件,会出现 一个Warning并且需要额外的处置 1. 传输阶段(此时源库数据需要置于 READ ONLY 模式) 1. 在源库端把表空间置为 READ ONLY 2. 最后一次执行前滚阶段的步骤 这个步骤会让目标系统的数据文件拷贝和源库数据文件完全一致并且产生必要导出文件。 在数据量非常大的情况下,这个步骤所花费的时间要显著的少于传统的 XTTS 方式,因为增量备份会很 小。 3. 使用数据泵把这个表空间的元数据导入至目标数据库 4. 把目标数据库的相关表空间置为 READ WRITE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值