从AIX将数据库迁移到Linux Oracle为11.2.0.4
下面操作可以用来创建一个名叫xtt的增量转换实例,增量转换home为/u01/app/oracle/product/11.2.0/db/dbs:
[oracle@jyrac1 dbs]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db/ [oracle@jyrac1 dbs]$ export ORACLE_SID=xtt [oracle@jyrac1 dbs]$ cat < < EOF > $ORACLE_HOME/dbs/init$ORACLE_SID.ora > db_name=xtt > compatible=11.2.0.4.0 > EOF [oracle@jyrac1 dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 18 10:15:02 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount ORACLE instance started. Total System Global Area 296493056 bytes Fixed Size 2252584 bytes Variable Size 239075544 bytes Database Buffers 50331648 bytes Redo Buffers 4833280 bytes
源数据库目录对象引用源数据库中当前存放数据文件的目录。例如,下面创建目录对象指向,数据文件存放目录/oracle11/oradata/jycs/jycs/,连接到源数据库房执行以下命令:
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 Connected as ldjc@129_2 SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /oracle11/oradata/jycs/jycs/system01.dbf /oracle11/oradata/jycs/jycs/sysaux01.dbf /oracle11/oradata/jycs/jycs/undotbs01.dbf /oracle11/oradata/jycs/jycs/users01.dbf /oracle11/oradata/jycs/jycs/example01.dbf /oracle11/oradata/jycs/jycs/cdzj01 /oracle11/oradata/jycs/jycs/ldjc01 7 rows selected SQL> create directory sourcedir as '/oracle11/oradata/jycs/jycs'; Directory created SQL> select platform_id from v$database; PLATFORM_ID ----------- 6
目标数据库目录对象引用目标数据库中将要存储数据文件的目录。这个目录是最终目标数据库将要存放数据文件的目录+DATADG/jyrac/datafile/,连接到目标数据库执行以下命令
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 Connected as sys@jyrac AS SYSDBA SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATADG/jyrac/datafile/system.259.930413057 +DATADG/jyrac/datafile/sysaux.258.930413055 +DATADG/jyrac/datafile/undotbs1.262.930413057 +DATADG/jyrac/datafile/users.263.930413057 +DATADG/jyrac/datafile/example.260.930413057 +DATADG/jyrac/datafile/undotbs2.261.930413057 +DATADG/jyrac/datafile/test01.dbf +DATADG/jyrac/datafile/sales_test_01.dbf +DATADG/jyrac/datafile/emp_test_01.dbf +DATADG/jyrac/datafile/orders_test_01.dbf 10 rows selected SQL> create directory destdir as '+DATADG/jyrac/datafile'; Directory created
在目标数据库中创建一个dblink连接到源数据库。例如创建一个名叫ttslink的dblink,执行以下命令:
SQL> create public database link ttslink 2 connect to system identified by "xxzx7817600" 3 using '(DESCRIPTION = 4 (ADDRESS_LIST = 5 (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.129.2)(PORT = 1521)) 6 ) 7 (CONNECT_DATA = 8 (SERVER = DEDICATED) 9 (SERVICE_NAME =jycs) 10 ) 11 )'; Database link created.
创建dblink后验证是否可以能过dblink访问源数据库
SQL> select * from dual@ttslink; D - X
在源系统与目标系统中创建预备目录,它们将被设置为xtt.properties文件中的backupformat(源系统中存放增量备份文件的目录),backupondest(目标系统中存放转换后的增量备份文件的目录)参数的值。如果使用RMAN备份方法,在源系统与目标系统中还需要为xtt.properties文件中的dfcopydir(源系统中存放数据文件副本的目录,只有使用rman备份才使用),stageondest(目标系统中存放从源系统传输过来的数据文件副本与增量备份的目录,只有使用rman备份才使用)。
在源系统中执行下面的命令分别创建backupformat目录(/oracle11/backup),dfcopydir目录(/oracle11/dfcopydir)
IBMP740-2:/oracle11$mkdir backup IBMP740-2:/oracle11$mkdir dfcopydir
在目标系统中执行下面的命令分别创建backupondest目录(+DATADG/backup),stagenodest目录(/u01/xtts)
ASMCMD [+datadg] > mkdir backup
如果ASM被用于存储xtt.properties文件中的参数backupondest,那么实例的compatible参数的值必须等于或大于ASM磁盘组所使用的rdbms.compatible的值。
[grid@jyrac1 ~]$ asmcmd lsattr -G DATADG -l Name Value access_control.enabled false access_control.umask 026 au_size 1048576 cell.smart_scan_capable FALSE compatible.asm 11.2.0.0.0 compatible.rdbms 11.2.0.0.0 disk_repair_time 4.5 H sector_size 512 [root@jyrac1 u01]# mkdir xtts [root@jyrac1 u01]# chown -R oracle:oinstall xtts [root@jyrac1 u01]# chmod 777 xtts
在源系统中安装xttconver脚本
在源系统中,使用Oracle软件用户,下裁与解压脚本
IBMP740-2:/oracle11/xtts_script$unzip rman_xttconvert_v3.zip Archive: rman_xttconvert_v3.zip inflating: xtt.properties inflating: xttcnvrtbkupdest.sql inflating: xttdbopen.sql inflating: xttdriver.pl inflating: xttprep.tmpl extracting: xttstartupnomount.sql IBMP740-2:/oracle11/xtts_script$ls -lrt total 416 -rw-r--r-- 1 oracle11 oinstall 1390 May 24 16:57 xttcnvrtbkupdest.sql -rw-r--r-- 1 oracle11 oinstall 52 May 24 16:57 xttstartupnomount.sql -rw-r--r-- 1 oracle11 oinstall 11710 May 24 16:57 xttprep.tmpl -rw-r--r-- 1 oracle11 oinstall 139331 May 24 16:57 xttdriver.pl -rw-r--r-- 1 oracle11 oinstall 71 May 24 16:57 xttdbopen.sql -rw-r--r-- 1 oracle11 oinstall 7969 Jun 05 08:47 xtt.properties -rw-r----- 1 oracle11 oinstall 33949 Aug 18 09:26 rman_xttconvert_v3.zip
在源系统中配置xtt.properties文件
IBMP740-2:/oracle11/xtts_script$vi xtt.properties tablespaces=CDZJ,LDJC platformid=6 srcdir=SOURCEDIR dstdir=DESTDIR srclink=ttslink #dfcopydir=/oracle11/dfcopydir backupformat=/oracle11/backup stageondest=/u01/xtts backupondest=+DATADG/backup #storageondest=+DATADG/jyrac/datafile/ cnvinst_home=/oracle11/app/oracle/product/11.2.0/db cnvinst_sid=xtt asm_home=/u01/app/product/11.2.0/crs asm_sid=+ASM1
将源系统中的转换脚本与xtt.properties文件复制到目标系统中
[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2 Connected to 10.138.129.2. 220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready. 502 authentication type cannot be set to GSSAPI 502 authentication type cannot be set to KERBEROS_V4 KERBEROS_V4 rejected as an authentication type Name (10.138.129.2:oracle): oracle 331 Password required for oracle. Password: 230-Last unsuccessful login: Wed Dec 3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31 230-Last login: Mon Aug 14 08:39:17 BEIST 2017 on /dev/pts/0 from 10.138.130.242 230 User oracle logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /oracle11/xtts_script 250 CWD command successful. ftp> ls -lrt 227 Entering Passive Mode (10,138,129,2,37,50) 150 Opening data connection for /bin/ls. total 424 -rw-r--r-- 1 oracle11 oinstall 1390 May 24 16:57 xttcnvrtbkupdest.sql -rw-r--r-- 1 oracle11 oinstall 52 May 24 16:57 xttstartupnomount.sql -rw-r--r-- 1 oracle11 oinstall 11710 May 24 16:57 xttprep.tmpl -rw-r--r-- 1 oracle11 oinstall 139331 May 24 16:57 xttdriver.pl -rw-r--r-- 1 oracle11 oinstall 71 May 24 16:57 xttdbopen.sql -rw-r--r-- 1 oracle11 oinstall 7969 Jun 05 08:47 xtt.properties.jy -rw-r----- 1 oracle11 oinstall 33949 Aug 18 09:26 rman_xttconvert_v3.zip -rw-r--r-- 1 oracle11 oinstall 352 Aug 18 10:15 xtt.properties 226 Transfer complete. ftp> lcd /u01/xtts_script Local directory now /u01/xtts_script ftp> bin 200 Type set to I. ftp> get xttcnvrtbkupdest.sql local: xttcnvrtbkupdest.sql remote: xttcnvrtbkupdest.sql 227 Entering Passive Mode (10,138,129,2,37,63) 150 Opening data connection for xttcnvrtbkupdest.sql (1390 bytes). 226 Transfer complete. 1390 bytes received in 4.8e-05 seconds (2.8e+04 Kbytes/s) ftp> get xttstartupnomount.sql local: xttstartupnomount.sql remote: xttstartupnomount.sql 227 Entering Passive Mode (10,138,129,2,37,66) 150 Opening data connection for xttstartupnomount.sql (52 bytes). 226 Transfer complete. 52 bytes received in 3.7e-05 seconds (1.4e+03 Kbytes/s) ftp> get xttprep.tmpl local: xttprep.tmpl remote: xttprep.tmpl 227 Entering Passive Mode (10,138,129,2,37,69) 150 Opening data connection for xttprep.tmpl (11710 bytes). 226 Transfer complete. 11710 bytes received in 0.00065 seconds (1.7e+04 Kbytes/s) ftp> get xttdriver.pl local: xttdriver.pl remote: xttdriver.pl 227 Entering Passive Mode (10,138,129,2,37,72) 150 Opening data connection for xttdriver.pl (139331 bytes). 226 Transfer complete. 139331 bytes received in 0.0026 seconds (5.3e+04 Kbytes/s) ftp> get xttdbopen.sql local: xttdbopen.sql remote: xttdbopen.sql 227 Entering Passive Mode (10,138,129,2,37,77) 150 Opening data connection for xttdbopen.sql (71 bytes). 226 Transfer complete. 71 bytes received in 3.9e-05 seconds (1.8e+03 Kbytes/s) ftp> get xtt.properties local: xtt.properties remote: xtt.properties 227 Entering Passive Mode (10,138,129,2,37,84) 150 Opening data connection for xtt.properties (352 bytes). 226 Transfer complete. 352 bytes received in 4.2e-05 seconds (8.2e+03 Kbytes/s) [oracle@jyrac1 xtts_script]$ ls -lrt total 172 -rw-r--r-- 1 oracle oinstall 1390 Aug 18 10:38 xttcnvrtbkupdest.sql -rw-r--r-- 1 oracle oinstall 52 Aug 18 10:38 xttstartupnomount.sql -rw-r--r-- 1 oracle oinstall 11710 Aug 18 10:38 xttprep.tmpl -rw-r--r-- 1 oracle oinstall 139331 Aug 18 10:38 xttdriver.pl -rw-r--r-- 1 oracle oinstall 71 Aug 18 10:38 xttdbopen.sql -rw-r--r-- 1 oracle oinstall 352 Aug 18 10:38 xtt.properties
在源系统与目标系统中设置环境变TMPDIR,它指向转换脚本所在的目录。为了执行Perl脚本xttdriver.pl设置如下。如果TMPDIR没有设置,那么脚本生成的输出文件将会存放在/tmp目录中。
IBMP740-2:/oracle11$export TMPDIR=/oracle11/xtts_script [oracle@jyrac1 xtts_script]$ export TMPDIR=/u01/xtts_script
2.准备阶段
在准备阶段,被传输表空间的数据文件会被传输到目标系统并且通过执行xttdriver.pl脚本进行转换。有以下两种方法可以使用:
1. dbms_file_transfer方法
2. RMAN备份方法
对于大量数据文件使用dbms_file_transfer方法要比传输数据文件到目标系统更快。
2a.使用dbms_file_transfer方法
2a.1在源系统中执行准备操作
在源系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令:
IBMP740-2:/oracle11/xtts_script$export ORACLE_HOME=/oracle11/app/oracle/product/11.2.0/db IBMP740-2:/oracle11/xtts_script$export ORACLE_SID=jycs IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -S ============================================================ trace file is /oracle11/xtts_script/setupgetfile_Aug18_Fri_10_21_17_169//Aug18_Fri_10_21_17_169_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Starting prepare phase -------------------------------------------------------------------- Prepare source for Tablespaces: 'CDZJ' /u01/xtts xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 10:21:17 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:21:18 2017 Prepare source for Tablespaces: 'LDJC' /u01/xtts xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 10:21:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:21:18 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 10:21:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:21:18 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 10:21:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:21:18 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 10:21:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:21:18 2017 -------------------------------------------------------------------- Done with prepare phase --------------------------------------------------------------------
准备操作将在源系统中执行以下操作
.验证表空间是否online,read write且不包含脱机数据文件
.将创建后面所要使用的以下文件:
xttnewdatafiles.txt
getfile.sql
IBMP740-2:/oracle11/xtts_script$cat xttnewdatafiles.txt ::CDZJ 6,DESTDIR:/cdzj01 ::LDJC 7,DESTDIR:/ldjc01 IBMP740-2:/oracle11/xtts_script$cat getfile.sql 0,SOURCEDIR,cdzj01,DESTDIR,cdzj01 1,SOURCEDIR,ldjc01,DESTDIR,ldjc01
要被传输的一组表空间必须是online,read write状态且不包含脱机数据文件。如果在源数据库中被传输表空间的一个或多个数据文件是脱机状态或read only就会触发错误。如果表空间在整个表空间传输过程中都保持read only状态,那么就使用传统的跨平台传输表空间,不要使用跨平台增量备份传输表空间。
2a.2 传输数据文件到目标系统中
在目标系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并复制上一步生成的xttnewdatafiles.txt与getfile.sql文件到目标系统并执行操作来获取数据文件
[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2 Connected to 10.138.129.2. 220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready. 502 authentication type cannot be set to GSSAPI 502 authentication type cannot be set to KERBEROS_V4 KERBEROS_V4 rejected as an authentication type Name (10.138.129.2:oracle): oracle 331 Password required for oracle. Password: 230-Last unsuccessful login: Wed Dec 3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31 230-Last login: Fri Aug 18 10:16:01 BEIST 2017 on ftp from ::ffff:10.138.130.151 230 User oracle logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /oracle11/xtts_script 250 CWD command successful. ftp> ls -lrt 227 Entering Passive Mode (10,138,129,2,38,79) 150 Opening data connection for /bin/ls. total 456 -rw-r--r-- 1 oracle11 oinstall 1390 May 24 16:57 xttcnvrtbkupdest.sql -rw-r--r-- 1 oracle11 oinstall 52 May 24 16:57 xttstartupnomount.sql -rw-r--r-- 1 oracle11 oinstall 11710 May 24 16:57 xttprep.tmpl -rw-r--r-- 1 oracle11 oinstall 139331 May 24 16:57 xttdriver.pl -rw-r--r-- 1 oracle11 oinstall 71 May 24 16:57 xttdbopen.sql -rw-r--r-- 1 oracle11 oinstall 7969 Jun 05 08:47 xtt.properties.jy -rw-r----- 1 oracle11 oinstall 33949 Aug 18 09:26 rman_xttconvert_v3.zip -rw-r--r-- 1 oracle11 oinstall 352 Aug 18 10:15 xtt.properties -rw-r--r-- 1 oracle11 oinstall 50 Aug 18 10:21 xttplan.txt -rw-r--r-- 1 oracle11 oinstall 106 Aug 18 10:21 xttnewdatafiles.txt_temp -rw-r--r-- 1 oracle11 oinstall 50 Aug 18 10:21 xttnewdatafiles.txt drwxr-xr-x 2 oracle11 oinstall 256 Aug 18 10:21 setupgetfile_Aug18_Fri_10_21_17_169 -rw-r--r-- 1 oracle11 oinstall 68 Aug 18 10:21 getfile.sql 226 Transfer complete. ftp> lcd /u01/xtts_script Local directory now /u01/xtts_script ftp> bin 200 Type set to I. ftp> get xttnewdatafiles.txt local: xttnewdatafiles.txt remote: xttnewdatafiles.txt 227 Entering Passive Mode (10,138,129,2,38,112) 150 Opening data connection for xttnewdatafiles.txt (50 bytes). 226 Transfer complete. 50 bytes received in 6.2e-05 seconds (7.9e+02 Kbytes/s) ftp> get getfile.sql local: getfile.sql remote: getfile.sql 227 Entering Passive Mode (10,138,129,2,38,115) 150 Opening data connection for getfile.sql (68 bytes). 226 Transfer complete. 68 bytes received in 4.9e-05 seconds (1.4e+03 Kbytes/s) # MUST set environment to destination database [oracle@jyrac1 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db [oracle@jyrac1 xtts_script]$ export ORACLE_SID=jyrac1 [oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G ============================================================ trace file is /u01/xtts_script/getfile_Aug18_Fri_11_03_48_564//Aug18_Fri_11_03_48_564_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Getting datafiles from source -------------------------------------------------------------------- -------------------------------------------------------------------- Executing getfile for /u01/xtts_script/getfile_Aug18_Fri_11_03_48_564//getfile_sourcedir_cdzj01_0.sql -------------------------------------------------------------------- -------------------------------------------------------------------- Executing getfile for /u01/xtts_script/getfile_Aug18_Fri_11_03_48_564//getfile_sourcedir_ldjc01_1.sql -------------------------------------------------------------------- -------------------------------------------------------------------- Completed getting datafiles from source -------------------------------------------------------------------- ASMCMD [+datadg/jyrac/datafile] > ls -lt Type Redund Striped Time Sys Name N ldjc01 => +DATADG/JYRAC/DATAFILE/FILE_TRANSFER.271.952340629 N cdzj01 => +DATADG/JYRAC/DATAFILE/FILE_TRANSFER.272.952340629 DATAFILE MIRROR COARSE AUG 18 11:00:00 Y FILE_TRANSFER.272.952340629 DATAFILE MIRROR COARSE AUG 18 11:00:00 Y FILE_TRANSFER.271.952340629
当这步操作完成后,要被传输的数据文件会存放在目标系统最终存放数据文件的目录中。转换操作会自动执行。下面就要执行前滚阶段的操作了。
3.前滚阶段
下面在源数据库中创建增量数据
SQL> insert into ldjc.jy_test values(7); 1 row inserted SQL> insert into cdzj.jy_test values(7); 1 row inserted SQL> commit; Commit complete SQL> select * from ldjc.jy_test; USER_ID --------------------- 7 1 2 3 4 5 6 7 rows selected SQL> select * from cdzj.jy_test; USER_ID --------------------- 7 1 2 3 4 5 6 7 rows selected
在这个阶段,会在源系统中对源数据库创建增量备份,然后将生成的增量备份传输到目标系统中,并将增量备份转换为目标系统所使用的字节序,然后将转换后的增量备份应用到转换后的数据文件进行前滚操作。这个阶段的操作可以执行多次,每一次成功的增量备份应该比之前的增量备份花费更少的时间,并且让目标系统中的数据文件的内容更加接近源数据库的内容。在这个阶段源数据库中被传输的数据完全可以被访问。
3.1 在源系统中对被传输的表空间LDJC,CDZJ创建增量备份
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -i ============================================================ trace file is /oracle11/xtts_script/incremental_Aug18_Fri_10_56_44_606//Aug18_Fri_10_56_44_606_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Backup incremental -------------------------------------------------------------------- Prepare source for Tablespaces: 'CDZJ' /u01/xtts xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 10:56:44 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:56:44 2017 Prepare source for Tablespaces: 'LDJC' /u01/xtts xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 10:56:44 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:56:44 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 10:56:44 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:56:44 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 10:56:44 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:56:44 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 10:56:44 2017 xttpreparesrc.sql for ended at Fri Aug 18 10:56:44 2017 ============================================================ No new datafiles added ============================================================= Prepare newscn for Tablespaces: 'CDZJ' Prepare newscn for Tablespaces: 'LDJC' Prepare newscn for Tablespaces: '''''''''''' -------------------------------------------------------------------- Starting incremental backup -------------------------------------------------------------------- -------------------------------------------------------------------- Done backing up incrementals --------------------------------------------------------------------
上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt
tsbkupmap.txt的内容如下:
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt LDJC::7:::1=07sc73ng_1_1 CDZJ::6:::1=06sc73nf_1_1
文件中的内容记录了表空间与增量备份的关联关系
incrbackups.txt的内容如下:
IBMP740-2:/oracle11/xtts_script$cat incrbackups.txt /oracle11/backup/07sc73ng_1_1 /oracle11/backup/06sc73nf_1_1
文件中的内容显示了生成的增量备份文件信息
IBMP740-2:/oracle11/backup$ls -lrt total 624 -rw-r----- 1 oracle11 oinstall 65536 Aug 18 10:56 06sc73nf_1_1 -rw-r----- 1 oracle11 oinstall 253952 Aug 18 10:56 07sc73ng_1_1
3.2 将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/u01/xtts)中。
[oracle@jyrac1 xtts]$ ftp 10.138.129.2 Connected to 10.138.129.2. 220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready. 502 authentication type cannot be set to GSSAPI 502 authentication type cannot be set to KERBEROS_V4 KERBEROS_V4 rejected as an authentication type Name (10.138.129.2:oracle): oracle 331 Password required for oracle. Password: 230-Last unsuccessful login: Wed Dec 3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31 230-Last login: Fri Aug 18 10:24:32 BEIST 2017 on ftp from ::ffff:10.138.130.151 230 User oracle logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /oracle11/backup 250 CWD command successful. ftp> ls -lrt 227 Entering Passive Mode (10,138,129,2,43,121) 150 Opening data connection for /bin/ls. total 624 -rw-r----- 1 oracle11 oinstall 65536 Aug 18 10:56 06sc73nf_1_1 -rw-r----- 1 oracle11 oinstall 253952 Aug 18 10:56 07sc73ng_1_1 226 Transfer complete. ftp> lcd /u01/xtts Local directory now /u01/xtts ftp> bin 200 Type set to I. ftp> get 06sc73nf_1_1 local: 06sc73nf_1_1 remote: 06sc73nf_1_1 227 Entering Passive Mode (10,138,129,2,43,130) 150 Opening data connection for 06sc73nf_1_1 (65536 bytes). 226 Transfer complete. 65536 bytes received in 0.0018 seconds (3.5e+04 Kbytes/s) ftp> get 07sc73ng_1_1 local: 07sc73ng_1_1 remote: 07sc73ng_1_1 227 Entering Passive Mode (10,138,129,2,43,134) 150 Opening data connection for 07sc73ng_1_1 (253952 bytes). 226 Transfer complete. 253952 bytes received in 0.0038 seconds (6.5e+04 Kbytes/s) [oracle@jyrac1 xtts]$ ls -lrt total 320 -rw-r--r-- 1 oracle oinstall 65536 Aug 18 11:22 06sc73nf_1_1 -rw-r--r-- 1 oracle oinstall 253952 Aug 18 11:22 07sc73ng_1_1
3.3 在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。
[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2 Connected to 10.138.129.2. 220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready. 502 authentication type cannot be set to GSSAPI 502 authentication type cannot be set to KERBEROS_V4 KERBEROS_V4 rejected as an authentication type Name (10.138.129.2:oracle): oracle 331 Password required for oracle. Password: 230-Last unsuccessful login: Wed Dec 3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31 230-Last login: Fri Aug 18 11:00:11 BEIST 2017 on ftp from ::ffff:10.138.130.151 230 User oracle logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /oracle11/xtts_script 250 CWD command successful. ftp> ls -lrt 227 Entering Passive Mode (10,138,129,2,43,196) 150 Opening data connection for /bin/ls. total 520 -rw-r--r-- 1 oracle11 oinstall 1390 May 24 16:57 xttcnvrtbkupdest.sql -rw-r--r-- 1 oracle11 oinstall 52 May 24 16:57 xttstartupnomount.sql -rw-r--r-- 1 oracle11 oinstall 11710 May 24 16:57 xttprep.tmpl -rw-r--r-- 1 oracle11 oinstall 139331 May 24 16:57 xttdriver.pl -rw-r--r-- 1 oracle11 oinstall 71 May 24 16:57 xttdbopen.sql -rw-r--r-- 1 oracle11 oinstall 7969 Jun 05 08:47 xtt.properties.jy -rw-r----- 1 oracle11 oinstall 33949 Aug 18 09:26 rman_xttconvert_v3.zip -rw-r--r-- 1 oracle11 oinstall 352 Aug 18 10:15 xtt.properties -rw-r--r-- 1 oracle11 oinstall 50 Aug 18 10:21 xttplan.txt -rw-r--r-- 1 oracle11 oinstall 106 Aug 18 10:21 xttnewdatafiles.txt_temp -rw-r--r-- 1 oracle11 oinstall 50 Aug 18 10:21 xttnewdatafiles.txt drwxr-xr-x 2 oracle11 oinstall 256 Aug 18 10:21 setupgetfile_Aug18_Fri_10_21_17_169 -rw-r--r-- 1 oracle11 oinstall 68 Aug 18 10:21 getfile.sql -rw-r--r-- 1 oracle11 oinstall 50 Aug 18 10:56 xttplan.txt_tmp -rw-r--r-- 1 oracle11 oinstall 106 Aug 18 10:56 xttnewdatafiles.txt.added_temp -rw-r--r-- 1 oracle11 oinstall 50 Aug 18 10:56 xttnewdatafiles.txt.added -rw-r--r-- 1 oracle11 oinstall 68 Aug 18 10:56 getfile.sql.added -rw-r--r-- 1 oracle11 oinstall 54 Aug 18 10:56 xttplan.txt.new -rw-r--r-- 1 oracle11 oinstall 50 Aug 18 10:56 tsbkupmap.txt drwxr-xr-x 2 oracle11 oinstall 4096 Aug 18 10:56 incremental_Aug18_Fri_10_56_44_606 -rw-r--r-- 1 oracle11 oinstall 60 Aug 18 10:56 incrbackups.txt 226 Transfer complete. ftp> lcd /u01/xtts_script Local directory now /u01/xtts_script ftp> get tsbkupmap.txt local: tsbkupmap.txt remote: tsbkupmap.txt 227 Entering Passive Mode (10,138,129,2,43,208) 150 Opening data connection for tsbkupmap.txt (50 bytes). 226 Transfer complete. 50 bytes received in 4.1e-05 seconds (1.2e+03 Kbytes/s) ftp> get xttplan.txt local: xttplan.txt remote: xttplan.txt 227 Entering Passive Mode (10,138,129,2,43,213) 150 Opening data connection for xttplan.txt (50 bytes). 226 Transfer complete. 50 bytes received in 4.8e-05 seconds (1e+03 Kbytes/s) [oracle@jyrac1 xtts_script]$ cat tsbkupmap.txt LDJC::7:::1=07sc73ng_1_1 CDZJ::6:::1=06sc73nf_1_1 [oracle@jyrac1 xtts_script]$ cat xttplan.txt CDZJ::::14690270660591 6 LDJC::::14690270660591 7 [oracle@jyrac1 xtts_script]$ export XTTDEBUG=1 [oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r ============================================================ trace file is /u01/xtts_script/rollforward_Aug18_Fri_11_34_08_253//Aug18_Fri_11_34_08_253_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- Key: backupondest Values: +DATADG/backup Key: platformid Values: 6 Key: backupformat Values: /oracle11/backup Key: srclink Values: ttslink Key: asm_sid Values: +ASM1 Key: dstdir Values: DESTDIR Key: cnvinst_home Values: /u01/app/oracle/product/11.2.0/db Key: cnvinst_sid Values: xtt Key: srcdir Values: SOURCEDIR Key: stageondest Values: /u01/xtts Key: tablespaces Values: CDZJ,LDJC Key: asm_home Values: /u01/app/product/11.2.0/crs -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- ARGUMENT tablespaces ARGUMENT platformid ARGUMENT backupformat ARGUMENT stageondest ARGUMENT backupondest -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- ORACLE_SID : jyrac1 ORACLE_HOME : /u01/app/oracle/product/11.2.0/db -------------------------------------------------------------------- Start rollforward -------------------------------------------------------------------- convert instance: /u01/app/oracle/product/11.2.0/db convert instance: xtt ORACLE instance started. Total System Global Area 2505338880 bytes Fixed Size 2255832 bytes Variable Size 687866920 bytes Database Buffers 1795162112 bytes Redo Buffers 20054016 bytes rdfno 6 BEFORE ROLLPLAN datafile number : 6 datafile name : +DATADG/jyrac/datafile/cdzj01 AFTER ROLLPLAN CONVERTED BACKUP PIECE+DATADG/backup/xib_06sc73nf_1_1_6 PL/SQL procedure successfully completed. Entering RollForward After applySetDataFile Done: applyDataFileTo Done: applyDataFileTo Done: RestoreSetPiece Done: RestoreBackupPiece PL/SQL procedure successfully completed. asmcmd rm +DATADG/backup/xib_06sc73nf_1_1_6 /u01/app/product/11.2.0/crs .. +ASM1
–这里显示的信息是说在前滚后不能删除增量备份文件,可以忽略这个错误
Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. ASMCMD: rdfno 7 BEFORE ROLLPLAN datafile number : 7 datafile name : +DATADG/jyrac/datafile/ldjc01 AFTER ROLLPLAN CONVERTED BACKUP PIECE+DATADG/backup/xib_07sc73ng_1_1_7 PL/SQL procedure successfully completed. Entering RollForward After applySetDataFile Done: applyDataFileTo Done: applyDataFileTo Done: RestoreSetPiece Done: RestoreBackupPiece PL/SQL procedure successfully completed. asmcmd rm +DATADG/backup/xib_07sc73ng_1_1_7 /u01/app/product/11.2.0/crs .. +ASM1
–这里显示的信息是说在前滚后不能删除增量备份文件,可以忽略这个错误
Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. ASMCMD: -------------------------------------------------------------------- End of rollforward phase --------------------------------------------------------------------
这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。
3.4 为下一次增量备份判断from_scn
再次生成增量数据
SQL> insert into ldjc.jy_test values(8); 1 row inserted SQL> insert into cdzj.jy_test values(8); 1 row inserted SQL> commit; Commit complete SQL> select * from ldjc.jy_test; USER_ID --------------------- 7 8 8 1 2 3 4 5 6 9 rows selected SQL> select * from cdzj.jy_test; USER_ID --------------------- 7 8 1 2 3 4 5 6 8 rows selected
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -s ============================================================ trace file is /oracle11/xtts_script/determinescn_Aug18_Fri_11_21_56_544//Aug18_Fri_11_21_56_544_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- Prepare newscn for Tablespaces: 'CDZJ' Prepare newscn for Tablespaces: 'LDJC' Prepare newscn for Tablespaces: '''' Prepare newscn for Tablespaces: '''' Prepare newscn for Tablespaces: '''' New /oracle11/xtts_script/xttplan.txt with FROM SCN's generated
这步操作会计算下一个from_scn,并记录在xttplan.txt文件中,当下次创建增量备份时会使用这个scn
IBMP740-2:/oracle11/xtts_script$cat xttplan.txt CDZJ::::14690270749458 6 LDJC::::14690270749458 7
3.5 再次重复前滚阶段或执行传输阶段
这里有两种选择:
1.如果如果将目标数据库中的数据文件与源数据库中的数据文件进行最接近的同步,那么就重复执行前滚操作。
2.如果目标数据库中的数据文件与源数据库中的数据文件已经达到所期望的接近,那么执行传输阶段的操作。
注意:如果从上一次增量备份后增加了一个新的表空间或者一个新的表空间名增加到xtt.properties文件中,那么将会出现以下错误:
Error: ------ The incremental backup was not taken as a datafile has been added to the tablespace: Please Do the following: -------------------------- 1. Copy fixnewdf.txt from source to destination temp dir 2. Copy backups:from to the in destination 3. On Destination, run $ORACLE_HOME/perl/bin/perl xttdriver.pl --fixnewdf 4. Re-execute the incremental backup in source: $ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpincr NOTE: Before running incremental backup, delete FAILED in source temp dir or run xttdriver.pl with -L option: $ORACLE_HOME/perl/bin/perl xttdriver.pl -L --bkpincr These instructions must be followed exactly as listed. The next incremental backup will include the new datafile.
我这里再次执行前滚操作
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -i ============================================================ trace file is /oracle11/xtts_script/incremental_Aug18_Fri_11_23_16_532//Aug18_Fri_11_23_16_532_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Backup incremental -------------------------------------------------------------------- Prepare source for Tablespaces: 'CDZJ' /u01/xtts xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 11:23:16 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:23:16 2017 Prepare source for Tablespaces: 'LDJC' /u01/xtts xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 11:23:16 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:23:16 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 11:23:16 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:23:17 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 11:23:17 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:23:17 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 11:23:17 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:23:17 2017 ============================================================ No new datafiles added ============================================================= Prepare newscn for Tablespaces: 'CDZJ' Prepare newscn for Tablespaces: 'LDJC' Prepare newscn for Tablespaces: '''''''''''' -------------------------------------------------------------------- Starting incremental backup -------------------------------------------------------------------- -------------------------------------------------------------------- Done backing up incrementals --------------------------------------------------------------------
上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt
tsbkupmap.txt的内容如下:
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
LDJC::7:::1=09sc7598_1_1
CDZJ::6:::1=08sc7597_1_1
文件中的内容记录了表空间与增量备份的关联关系
incrbackups.txt的内容如下:
IBMP740-2:/oracle11/xtts_script$cat incrbackups.txt /oracle11/backup/09sc7598_1_1 /oracle11/backup/08sc7597_1_1
文件中的内容显示了生成的增量备份文件信息
IBMP740-2:/oracle11/backup$ls -lrt -rw-r----- 1 oracle11 oinstall 49152 Aug 18 11:23 08sc7597_1_1 -rw-r----- 1 oracle11 oinstall 204800 Aug 18 11:23 09sc7598_1_1
将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/u01/xtts)中。
[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2 Connected to 10.138.129.2. 220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready. 502 authentication type cannot be set to GSSAPI 502 authentication type cannot be set to KERBEROS_V4 KERBEROS_V4 rejected as an authentication type Name (10.138.129.2:oracle): oracle 331 Password required for oracle. Password: 230-Last unsuccessful login: Wed Dec 3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31 230-Last login: Fri Aug 18 11:02:13 BEIST 2017 on ftp from ::ffff:10.138.130.151 230 User oracle logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /oracle11/backup 250 CWD command successful. ftp> ls -lrt 227 Entering Passive Mode (10,138,129,2,46,249) 150 Opening data connection for /bin/ls. total 1120 -rw-r----- 1 oracle11 oinstall 65536 Aug 18 10:56 06sc73nf_1_1 -rw-r----- 1 oracle11 oinstall 253952 Aug 18 10:56 07sc73ng_1_1 -rw-r----- 1 oracle11 oinstall 49152 Aug 18 11:23 08sc7597_1_1 -rw-r----- 1 oracle11 oinstall 204800 Aug 18 11:23 09sc7598_1_1 226 Transfer complete. ftp> lcd /u01/xtts Local directory now /u01/xtts ftp> bin 200 Type set to I. ftp> get 08sc7597_1_1 local: 08sc7597_1_1 remote: 08sc7597_1_1 227 Entering Passive Mode (10,138,129,2,47,4) 150 Opening data connection for 08sc7597_1_1 (49152 bytes). 226 Transfer complete. 49152 bytes received in 0.0013 seconds (3.7e+04 Kbytes/s) ftp> get 09sc7598_1_1 local: 09sc7598_1_1 remote: 09sc7598_1_1 227 Entering Passive Mode (10,138,129,2,47,9) 150 Opening data connection for 09sc7598_1_1 (204800 bytes). 226 Transfer complete. 204800 bytes received in 0.0029 seconds (7e+04 Kbytes/s)
在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。
ftp> cd /oracle11/xtts_script 250 CWD command successful. ftp> lcd /u01/xtts_script Local directory now /u01/xtts_script ftp> bin 200 Type set to I. ftp> get xttplan.txt local: xttplan.txt remote: xttplan.txt 227 Entering Passive Mode (10,138,129,2,47,32) 150 Opening data connection for xttplan.txt (54 bytes). 226 Transfer complete. 54 bytes received in 2.7e-05 seconds (2e+03 Kbytes/s) ftp> get tsbkupmap.txt local: tsbkupmap.txt remote: tsbkupmap.txt 227 Entering Passive Mode (10,138,129,2,47,39) 150 Opening data connection for tsbkupmap.txt (50 bytes). 226 Transfer complete. 50 bytes received in 3.2e-05 seconds (1.5e+03 Kbytes/s) [oracle@jyrac1 xtts_script]$ cat xttplan.txt CDZJ::::14690270749458 6 LDJC::::14690270749458 7 [oracle@jyrac1 xtts_script]$ cat tsbkupmap.txt LDJC::7:::1=09sc7598_1_1 CDZJ::6:::1=08sc7597_1_1 [oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r ============================================================ trace file is /u01/xtts_script/rollforward_Aug18_Fri_11_50_48_600//Aug18_Fri_11_50_48_600_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- Key: backupondest Values: +DATADG/backup Key: platformid Values: 6 Key: backupformat Values: /oracle11/backup Key: srclink Values: ttslink Key: asm_sid Values: +ASM1 Key: dstdir Values: DESTDIR Key: cnvinst_home Values: /u01/app/oracle/product/11.2.0/db Key: cnvinst_sid Values: xtt Key: srcdir Values: SOURCEDIR Key: stageondest Values: /u01/xtts Key: tablespaces Values: CDZJ,LDJC Key: asm_home Values: /u01/app/product/11.2.0/crs -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- ARGUMENT tablespaces ARGUMENT platformid ARGUMENT backupformat ARGUMENT stageondest ARGUMENT backupondest -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- ORACLE_SID : jyrac1 ORACLE_HOME : /u01/app/oracle/product/11.2.0/db -------------------------------------------------------------------- Start rollforward -------------------------------------------------------------------- convert instance: /u01/app/oracle/product/11.2.0/db convert instance: xtt ORACLE instance started. Total System Global Area 2505338880 bytes Fixed Size 2255832 bytes Variable Size 687866920 bytes Database Buffers 1795162112 bytes Redo Buffers 20054016 bytes rdfno 6 BEFORE ROLLPLAN datafile number : 6 datafile name : +DATADG/jyrac/datafile/cdzj01 AFTER ROLLPLAN CONVERTED BACKUP PIECE+DATADG/backup/xib_08sc7597_1_1_6 PL/SQL procedure successfully completed. Entering RollForward After applySetDataFile Done: applyDataFileTo Done: applyDataFileTo Done: RestoreSetPiece Done: RestoreBackupPiece PL/SQL procedure successfully completed. asmcmd rm +DATADG/backup/xib_08sc7597_1_1_6 /u01/app/product/11.2.0/crs .. +ASM1 Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. ASMCMD: rdfno 7 BEFORE ROLLPLAN datafile number : 7 datafile name : +DATADG/jyrac/datafile/ldjc01 AFTER ROLLPLAN CONVERTED BACKUP PIECE+DATADG/backup/xib_09sc7598_1_1_7 PL/SQL procedure successfully completed. Entering RollForward After applySetDataFile Done: applyDataFileTo Done: applyDataFileTo Done: RestoreSetPiece Done: RestoreBackupPiece PL/SQL procedure successfully completed. asmcmd rm +DATADG/backup/xib_09sc7598_1_1_7 /u01/app/product/11.2.0/crs .. +ASM1 Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. ASMCMD: -------------------------------------------------------------------- End of rollforward phase --------------------------------------------------------------------
这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。
为下一次增量备份判断from_scn
再次生成增量数据
SQL> insert into ldjc.jy_test values(9); 1 row inserted SQL> insert into cdzj.jy_test values(9); 1 row inserted SQL> commit; Commit complete SQL> select * from ldjc.jy_test; USER_ID --------------------- 7 8 8 9 1 2 3 4 5 6 10 rows selected SQL> select * from cdzj.jy_test; USER_ID --------------------- 7 8 9 1 2 3 4 5 6 9 rows selected
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -s ============================================================ trace file is /oracle11/xtts_script/determinescn_Aug18_Fri_11_31_22_441//Aug18_Fri_11_31_22_441_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- Prepare newscn for Tablespaces: 'CDZJ' Prepare newscn for Tablespaces: 'LDJC' Prepare newscn for Tablespaces: '''' Prepare newscn for Tablespaces: '''' Prepare newscn for Tablespaces: '''' New /oracle11/xtts_script/xttplan.txt with FROM SCN's generated IBMP740-2:/oracle11/xtts_script$cat xttplan.txt CDZJ::::14690270749827 6 LDJC::::14690270749845
4.传输阶段
在执行传输阶段操作时,源数据库中被传输表空间要设置为read only状态,并且通过创建与应用最后一次的增量备份使用目标数据库中的数据文件与源数据库中的数据文件内容保持一致。在目标数据库数据文件与源数据库数据文件内容达成一致后,在源系统中执行正常的传输表空间操作来导出元数据,然后将元数据导入到目标数据库中。直到传输阶段操作完成之前,被传输的数据只能以read only模式被访问。
4.1 将源数据库中被传输表空间设置为read only状态
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令将表空间设置为read only:
SQL> alter tablespace ldjc read only; Tablespace altered SQL> alter tablespace cdzj read only; Tablespace altered SQL> select tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE USERS ONLINE EXAMPLE ONLINE CDZJ READ ONLY LDJC READ ONLY 8 rows selected
4.2 最后一次创建增量备份,并传输到目标系统且执行转换并应用到目标数据文件
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -i ============================================================ trace file is /oracle11/xtts_script/incremental_Aug18_Fri_11_33_18_477//Aug18_Fri_11_33_18_477_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- -------------------------------------------------------------------- Backup incremental -------------------------------------------------------------------- Prepare source for Tablespaces: 'CDZJ' /u01/xtts xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 11:33:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:33:18 2017 Prepare source for Tablespaces: 'LDJC' /u01/xtts xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 11:33:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:33:18 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 11:33:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:33:18 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 11:33:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:33:18 2017 Prepare source for Tablespaces: '''' /u01/xtts xttpreparesrc.sql for '''' started at Fri Aug 18 11:33:18 2017 xttpreparesrc.sql for ended at Fri Aug 18 11:33:18 2017 ============================================================ No new datafiles added ============================================================= Prepare newscn for Tablespaces: 'CDZJ' Prepare newscn for Tablespaces: 'LDJC' Prepare newscn for Tablespaces: '''''''''''' -------------------------------------------------------------------- Starting incremental backup -------------------------------------------------------------------- -------------------------------------------------------------------- Done backing up incrementals --------------------------------------------------------------------
上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt
tsbkupmap.txt的内容如下:
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt LDJC::7:::1=0bsc75s2_1_1 CDZJ::6:::1=0asc75s0_1_1
文件中的内容记录了表空间与增量备份的关联关系
incrbackups.txt的内容如下:
IBMP740-2:/oracle11/xtts_script$cat incrbackups.txt /oracle11/backup/0bsc75s2_1_1 /oracle11/backup/0asc75s0_1_1
将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/u01/xtts)中。
[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2 Connected to 10.138.129.2. 220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready. 502 authentication type cannot be set to GSSAPI 502 authentication type cannot be set to KERBEROS_V4 KERBEROS_V4 rejected as an authentication type Name (10.138.129.2:oracle): oracle 331 Password required for oracle. Password: 230-Last unsuccessful login: Wed Dec 3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31 230-Last login: Fri Aug 18 11:26:03 BEIST 2017 on ftp from ::ffff:10.138.130.151 230 User oracle logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /oracle11/backup 250 CWD command successful. ftp> ls -lrt 227 Entering Passive Mode (10,138,129,2,48,62) 150 Opening data connection for /bin/ls. total 1632 -rw-r----- 1 oracle11 oinstall 65536 Aug 18 10:56 06sc73nf_1_1 -rw-r----- 1 oracle11 oinstall 253952 Aug 18 10:56 07sc73ng_1_1 -rw-r----- 1 oracle11 oinstall 49152 Aug 18 11:23 08sc7597_1_1 -rw-r----- 1 oracle11 oinstall 204800 Aug 18 11:23 09sc7598_1_1 -rw-r----- 1 oracle11 oinstall 49152 Aug 18 11:33 0asc75s0_1_1 -rw-r----- 1 oracle11 oinstall 212992 Aug 18 11:33 0bsc75s2_1_1 226 Transfer complete. ftp> lcd /u01/xtts Local directory now /u01/xtts ftp> get 0asc75s0_1_1 local: 0asc75s0_1_1 remote: 0asc75s0_1_1 227 Entering Passive Mode (10,138,129,2,48,73) 150 Opening data connection for 0asc75s0_1_1 (49152 bytes). 226 Transfer complete. 49152 bytes received in 0.0015 seconds (3.3e+04 Kbytes/s) ftp> get 0bsc75s2_1_1 local: 0bsc75s2_1_1 remote: 0bsc75s2_1_1 227 Entering Passive Mode (10,138,129,2,48,76) 150 Opening data connection for 0bsc75s2_1_1 (212992 bytes). 226 Transfer complete. 212992 bytes received in 0.0032 seconds (6.6e+04 Kbytes/s)
在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。
ftp> cd /oracle11/xtts_script 250 CWD command successful. ftp> lcd /u01/xtts_script Local directory now /u01/xtts_script ftp> bin 200 Type set to I. ftp> get xttplan.txt local: xttplan.txt remote: xttplan.txt 227 Entering Passive Mode (10,138,129,2,48,100) 150 Opening data connection for xttplan.txt (54 bytes). 226 Transfer complete. 54 bytes received in 3.4e-05 seconds (1.6e+03 Kbytes/s) ftp> get tsbkupmap.txt local: tsbkupmap.txt remote: tsbkupmap.txt 227 Entering Passive Mode (10,138,129,2,48,107) 150 Opening data connection for tsbkupmap.txt (50 bytes). 226 Transfer complete. 50 bytes received in 6.4e-05 seconds (7.6e+02 Kbytes/s) [oracle@jyrac1 xtts_script]$ cat xttplan.txt CDZJ::::14690270749827 6 LDJC::::14690270749845 7 [oracle@jyrac1 xtts_script]$ cat tsbkupmap.txt LDJC::7:::1=0bsc75s2_1_1 CDZJ::6:::1=0asc75s0_1_1 [oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r ============================================================ trace file is /u01/xtts_script/rollforward_Aug18_Fri_12_00_02_120//Aug18_Fri_12_00_02_120_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- Key: backupondest Values: +DATADG/backup Key: platformid Values: 6 Key: backupformat Values: /oracle11/backup Key: srclink Values: ttslink Key: asm_sid Values: +ASM1 Key: dstdir Values: DESTDIR Key: cnvinst_home Values: /u01/app/oracle/product/11.2.0/db Key: cnvinst_sid Values: xtt Key: srcdir Values: SOURCEDIR Key: stageondest Values: /u01/xtts Key: tablespaces Values: CDZJ,LDJC Key: asm_home Values: /u01/app/product/11.2.0/crs -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- ARGUMENT tablespaces ARGUMENT platformid ARGUMENT backupformat ARGUMENT stageondest ARGUMENT backupondest -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- ORACLE_SID : jyrac1 ORACLE_HOME : /u01/app/oracle/product/11.2.0/db -------------------------------------------------------------------- Start rollforward -------------------------------------------------------------------- convert instance: /u01/app/oracle/product/11.2.0/db convert instance: xtt ORACLE instance started. Total System Global Area 2505338880 bytes Fixed Size 2255832 bytes Variable Size 687866920 bytes Database Buffers 1795162112 bytes Redo Buffers 20054016 bytes rdfno 6 BEFORE ROLLPLAN datafile number : 6 datafile name : +DATADG/jyrac/datafile/cdzj01 AFTER ROLLPLAN CONVERTED BACKUP PIECE+DATADG/backup/xib_0asc75s0_1_1_6 PL/SQL procedure successfully completed. Entering RollForward After applySetDataFile Done: applyDataFileTo Done: applyDataFileTo Done: RestoreSetPiece Done: RestoreBackupPiece PL/SQL procedure successfully completed. asmcmd rm +DATADG/backup/xib_0asc75s0_1_1_6 /u01/app/product/11.2.0/crs .. +ASM1 Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. ASMCMD: rdfno 7 BEFORE ROLLPLAN datafile number : 7 datafile name : +DATADG/jyrac/datafile/ldjc01 AFTER ROLLPLAN CONVERTED BACKUP PIECE+DATADG/backup/xib_0bsc75s2_1_1_7 PL/SQL procedure successfully completed. Entering RollForward After applySetDataFile Done: applyDataFileTo Done: applyDataFileTo Done: RestoreSetPiece Done: RestoreBackupPiece PL/SQL procedure successfully completed. asmcmd rm +DATADG/backup/xib_0bsc75s2_1_1_7 /u01/app/product/11.2.0/crs .. +ASM1 Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143. ASMCMD: -------------------------------------------------------------------- End of rollforward phase --------------------------------------------------------------------
4.3 在目标数据库中导入元数据
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来生成Data Pump TTS命令:
[oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -e ============================================================ trace file is /u01/xtts_script/generate_Aug18_Fri_12_01_00_366//Aug18_Fri_12_01_00_366_.log ============================================================= -------------------------------------------------------------------- Parsing properties -------------------------------------------------------------------- Key: backupondest Values: +DATADG/backup Key: platformid Values: 6 Key: backupformat Values: /oracle11/backup Key: srclink Values: ttslink Key: asm_sid Values: +ASM1 Key: dstdir Values: DESTDIR Key: cnvinst_home Values: /u01/app/oracle/product/11.2.0/db Key: cnvinst_sid Values: xtt Key: srcdir Values: SOURCEDIR Key: stageondest Values: /u01/xtts Key: tablespaces Values: CDZJ,LDJC Key: asm_home Values: /u01/app/product/11.2.0/crs -------------------------------------------------------------------- Done parsing properties -------------------------------------------------------------------- -------------------------------------------------------------------- Checking properties -------------------------------------------------------------------- ARGUMENT tablespaces ARGUMENT platformid ARGUMENT backupformat ARGUMENT stageondest -------------------------------------------------------------------- Done checking properties -------------------------------------------------------------------- ORACLE_SID : jyrac1 ORACLE_HOME : /u01/app/oracle/product/11.2.0/db -------------------------------------------------------------------- Generating plugin -------------------------------------------------------------------- -------------------------------------------------------------------- Done generating plugin file /u01/xtts_script/xttplugin.txt -------------------------------------------------------------------- [oracle@jyrac1 xtts_script]$ cat xttplugin.txt impdp directory=logfile= \ network_link= transport_full_check=no \ transport_tablespaces=CDZJ,LDJC \ transport_datafiles='+DATADG/jyrac/datafile/cdzj01','+DATADG/jyrac/datafile/ldjc01'
上面的命令会生成一个名叫xttplugin.txt的文件,文件创建了一个使用network_link参数执行传输表空间导入元数据的命令。命令中的transport_tablespaces与transport_datafiles参数已经设置正确。注意network_link模式指示导入通过使用dblink来完成,就不需要执行导出或使用dump文件。如果选择执行这个命令来完成表空间的传输就需要修改directory,logfile与network_link参数
SQL> create directory dump_dir as '/u01/xtts_script'; Directory created. SQL> grant read,write on directory dump_dir to public; Grant succeeded.
在目标数据库中创建用户方案LDJC,CDZJ
SQL> create user ldjc identified by "ldjc"; User created. SQL> grant dba,connect,resource to ldjc; Grant succeeded. SQL> create user cdzj identified by "cdzj"; User created. SQL> grant dba,connect,resource to cdzj; Grant succeeded. [oracle@jyrac1 xtts_script]$ impdp system/abcd directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles='+DATADG/jyrac/datafile/cdzj01','+DATADG/jyrac/datafile/ldjc01' Import: Release 11.2.0.4.0 - Production on Fri Aug 18 12:05:05 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 Testing options Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03": system/******** directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles=+DATADG/jyrac/datafile/cdzj01,+DATADG/jyrac/datafile/ldjc01 Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK Processing object type TRANSPORTABLE_EXPORT/TABLE Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS Processing object type TRANSPORTABLE_EXPORT/COMMENT Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03" successfully completed at Fri Aug 18 12:07:05 2017 elapsed 0 00:01:52 [oracle@jyrac1 xtts_script]$ impdp system/abcd directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink Import: Release 11.2.0.4.0 - Production on Fri Aug 18 12:09:15 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 Testing options Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01": system/******** directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink Processing object type SCHEMA_EXPORT/USER ORA-31684: Object type USER:"LDJC" already exists ORA-31684: Object type USER:"CDZJ" already exists Processing object type SCHEMA_EXPORT/SYSTEM_GRANT Processing object type SCHEMA_EXPORT/ROLE_GRANT Processing object type SCHEMA_EXPORT/DEFAULT_ROLE Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC Processing object type SCHEMA_EXPORT/DB_LINK Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION Processing object type SCHEMA_EXPORT/VIEW/VIEW ORA-39082: Object type VIEW:"LDJC"."TEMP_AAB002" created with compilation warnings Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_PKG" created with compilation warnings ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_SQLTRACE" created with compilation warnings Processing object type SCHEMA_EXPORT/JOB Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCOBJ Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 5 error(s) at Fri Aug 18 12:09:46 2017 elapsed 0 00:00:30 SQL> select * from ldjc.jy_test; USER_ID --------------------- 7 8 8 9 1 2 3 4 5 6 10 rows selected SQL> select * from cdzj.jy_test; USER_ID --------------------- 7 8 9 1 2 3 4 5 6 9 rows selected
元数据导入后,可以将源数据库中的表空间ldjc,cdzj修改为read write状态
SQL> alter tablespace ldjc read write; Tablespace altered. SQL> alter tablespace cdzj read write; Tablespace altered.
如果不使用network_link执行导入,那么可以执行传输表空间模式的data pump导出元数据,然后将元数据复制到目标数据库,再执行导入。
4.4 将目标数据库中的表空间ldjc,cdzj修改为read write状态
SQL> select tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE USERS ONLINE EXAMPLE ONLINE CDZJ READ ONLY LDJC READ ONLY 8 rows selected. SQL> alter tablespace ldjc read write; Tablespace altered. SQL> alter tablespace cdzj read write; Tablespace altered. SQL> select tablespace_name,status from dba_tablespaces; TABLESPACE_NAME STATUS ------------------------------ --------- SYSTEM ONLINE SYSAUX ONLINE UNDOTBS1 ONLINE TEMP ONLINE USERS ONLINE EXAMPLE ONLINE CDZJ ONLINE LDJC ONLINE 8 rows selected.
4.5 验证传输的数据
在这一步,在目标数据库中被传输过来的表空间设置为read only状态,然后运行应用程序来进行验证。也可以使用RMAN来检查物理与逻辑块损坏的情况。
[oracle@jyrac1 dbs]$ export ORACLE_SID=jyrac1 [oracle@jyrac1 dbs]$ rman target/ Recovery Manager: Release 11.2.0.4.0 - Production on Fri Aug 18 12:13:13 2017 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: JYRAC (DBID=2655496871) RMAN> validate tablespace LDJC,CDZJ check logical; Starting validate at 18-AUG-17 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=139 instance=jyrac1 device type=DISK channel ORA_DISK_1: starting validation of datafile channel ORA_DISK_1: specifying datafile(s) for validation input datafile file number=00012 name=+DATADG/jyrac/datafile/ldjc01 input datafile file number=00011 name=+DATADG/jyrac/datafile/cdzj01 channel ORA_DISK_1: validation complete, elapsed time: 00:01:05 List of Datafiles ================= File Status Marked Corrupt Empty Blocks Blocks Examined High SCN ---- ------ -------------- ------------ --------------- ---------- 11 OK 0 255625 262144 14690270752496 File Name: +DATADG/jyrac/datafile/cdzj01 Block Type Blocks Failing Blocks Processed ---------- -------------- ---------------- Data 0 6239 Index 0 0 Other 0 280 File Status Marked Corrupt Empty Blocks Blocks Examined High SCN ---- ------ -------------- ------------ --------------- ---------- 12 OK 0 3746 655360 14690292001658 File Name: +DATADG/jyrac/datafile/ldjc01 Block Type Blocks Failing Blocks Processed ---------- -------------- ---------------- Data 0 361625 Index 0 286299 Other 0 3690 Finished validate at 18-AUG-17
5.清除阶段
如果为了迁移创建了单独的转换home与实例,那么在传输表空间操作完成之后可以关闭实例并删除软件。为了执行跨平台增量备份传输表空间而创建的文件与目录也可以删除了,例如:
.源系统中的dfcopydir目录
.源系统中的backupformat目录
.目标系统中的stageondest目录
.目标系统中的backupondest目录
.源系统与目标系统中的$TMPDIR环境变量
Perl脚本xttdriver.pl选项
-S 准备传输源:-S选项只有当使用dbms_file_transfer方法传输数据文件时使用。这个准备操作在源系统中只对源数据库执行一次。这步操作将创建xttnewdatafiles.txt与getfile.sql文件
-G 从源系统获取数据文件:-G选项只有当使用dbms_file_transfer方法传输数据文件时使用。获取数据文件操作在目标系统中对目标数据库只执行一次。-S选项必须在它之前执行一次,并将生成的xttnewdatafiles.txt与getfile.sql文件传输到目标系统。-G选项会连接到目标数据库并执行脚本getfile.sql。getfile.sql将调用dbms_file_transfer.get_file()过程通过使用dblink(srclink)来从源数据库的目录对象(srcdir)中获取要被传输的数据文件到目标数据库的目录对象(dstdir)中。
-p 准备对源数据库执行备份:-p选项只有当使用RMAN备份方法来生成数据文件副本时才使用。这步操作在源系统中对源数据库只执行一次。这步操作会连接到源数据库并对要被传输的每个表空间执行一次xttpreparesrc.sql脚本。xttpreparesrc.sql会执行以下操作:
1.验证表空间是否处于online,read write模式与是否不包含脱机数据文件
2.标识第一次执行增量备份操作时所需要使用的SCN信息并将它们写入$TMPDIR目录中的xttplan.txt文件中
3.在源系统中会在xtt.properties文件的dfcopydir参数所指定的目录中创建初始化数据文件副本。这些数据文件副本必须手动传输到目标每张
4.创建RMAN脚本$TMPDIR/rmanconvert.cmd,在目标系统中它将被用来将数据文件副本的字节序转换为目标系统所使用的字节序
-c 转换数据文件:-c选项只有当使用RMAN备份创建初始化数据文件副本时才使用。在目标系统中转换数据文件副本只执行一次。这步操作将使用rmanconvert.cmd文件来将数据文件副本转换为目标系统所使用的字节序。转换后的数据文件副本会被存储到xtt.properties文件的storageondest参数所指定的目录中,也就是最终目标数据库存储数据文件的目录。
-i 创建增量备份: 创建增量备份可以对源数据库执行一次或多次。这个步骤会读取$TMPDIR/xttplan.txt中所记录的SCN并生成用于前滚目标系统上数据文件副本的增量备份文件。
-r 前滚数据文件:对于创建的每个增量备份都会对目标数据库的数据文件进行前滚操作。这步操作会连接到cnvinst_home与cnvinst_sid所定义的增量转换实例,转换所创建的增量备份,那么连接到目标数据库对数据文件应用增量备份进行前滚操作。
-s 判断新的from_scn:对源数据库判断新的from_scn可以执行一次或多次。这步操作会计算下次增量备份所需要的from_scn,并将其记录在xttplan.txt文件中,然后当下一次创建增量备份的就会使用它。
-e 生成Data Pump TTS命令:在目标系统中对目标数据库只执行一次来生成Data Pump TTS命令。这步操作将创建一个使用dblink来导入元数据的Data Pump Import命令
-d debug:-d选项能以debug模式来执行xttdriver.pl与RMAN命令。要启用debug模式需要设置环境变量XTTDEBUG=1
xtt.properties文件参数说明
tablespaces:用逗号来分隔从源数据库要被传输到目标数据库的表空间列表,例如tablespaces=TS1,TS2
platformid:从v$database.platform_id获得的源数据库的platform id,例如platformid=13
srcdir:源数据库中的目录对象,它指向源数据库中存储数据文件的目录。多个目录可以使用逗号进行分隔。srcdir与dstdir的映射可以是N:1或N:N。例如可以有多个源目录且文件存储到单个目标目录或者文件来自一个特定源目录将被存储到一个特定的目标目录。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srcdir=SOURCEDIR,srcdir=SRC1,SRC2
dstdir:目标数据库中的目录对象,它指向目标数据库中存储数据文件的目录。如果使用了多个源目录(srcdir),那么可以定义多个目标目录以便将特定源目录中的文件写入特定的目标目录中。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如dstdir=DESTDIR,dstdir=DST1,DST2
srclink:目标数据库中连接到源数据库的dblink。使用dbms_file_transfer传输数据文件时会使用这个dblink。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srclink=ttslink
dfcopydir:源系统中用来存储xttdriver.pl -p操作所生成的数据文件副本目录。这个目录要有足够的空间来存储所有被传输表空间的数据文件副本。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。 这个参数只有使用RMAN备份生成数据文件副本时才使用,例如dfcopydir=/stage_source
backupformat:源系统中存储增量备份文件的目录。这个目录必须要有足够的空间来存储所有创建的增量备份文件。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。例如,backupformat=/stage_source
stageondest:目标系统中存储从源系统中手动传输过来的数据文件副本。这个目录要有足够的空间来存储数据文件副本。这个目录同时也是用来存储从源系统传输过来的增量备份文件的目录。在目标系统上执行xttdriver.pl -c转换数据文件与执行xttdriver.pl -r前滚数据文件时会从这个目录中读取数据文件副本与增量备份文件。这个目标也可以是一个DBFS-mounted文件系统。个目录可以是源系统上通过NFS-mounted文件系统所挂载到目标系统中的一个目录,在这种情况下,源系统中的backupformat参数与dfcopydir参数就会引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。例如stageondest=/stage_dest
storageondest:目标系统中用来存储xttdriver.pl -c转换操作后所生成的数据文件副本的目录,也就是目标数据库最终存储数据文件的目录。这个目录要有足够的空间来永久存储数据文件。这个参数当使用RMAN备份来生成初始化数据文件副本时才使用,例如
storageondest=+DATA或者storageondest=/oradata/test
backupondest:目录系统中用来存储xttdriver.pl -r前滚操作所转换后的增量备份文件的目录。这个目录要有足够的空间来存储转换后的增量备份文件。注意,如果这个参数指向ASM磁盘目录,那么需要在xtt.properties参数文件中定义asm_home与asm_sid参数。如果这个参数指向文件系统目录,那么就从xtt.properties参数文件中删除asm_home与asm_sid参数。例如,backupondest=+RECO
cnvinst_home:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_HOME,例如cnvinst_home=/u01/app/oracle/product/11.2.0.4/xtt_home
cnvinst_sid:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_SID,例如cnvinst_xtt
asm_home:目标系统中ASM实例的ORACLE_HOME。注意如果backupondest设置为文件系统目录,那么就要删除asm_home与asm_sid参数,例如asm_home=/u01/app/11.2.0.4/grid
asm_sid:目标系统中ASM实例的ORACLE_SID。例如asm_sid=+ASM1
parallel:定义rmanconvert.cmd命令文件中rman convert命令的并行度。如果不设置这个参数,那么xttdriver.pl将使用parallel=8的缺省并行度。例如,parallel=3
rollparallel:定义xttdriver.pl -r前滚操作的并行度,例如rollparallel=2
getfileparallel:定义xttdriver.pl -G获取数据文件副本操作的并行度,缺省值是1,最大值为8,例如getfileparallel=4