xtts from檔案系統到ASM儲存(dbms_file_transfer)
從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
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2150312/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 透過xtts遷移單例項檔案系統表空間到RAC ASM儲存表空間TTS單例ASM
- 通過xtts遷移單例項檔案系統表空間到RAC ASM儲存表空間TTS單例ASM
- 把檔案系統的資料檔案遷移到ASM儲存ASM
- ASM與檔案系統之間copy資料檔案--檔案系統到ASMASM
- asm拷貝檔案到檔案系統ASM
- 將ASM裡面的檔案copy到檔案系統ASM
- 使用dbms_file_transfer轉換ASM檔案ASM
- 儲存檔案到本地
- 移動資料檔案從ASM到檔案系統ASM
- 如何遷移ASM資料檔案到檔案系統ASM
- 04 磁碟儲存和檔案系統
- 使用dbms_file_transfer從asm中抽取檔案ASM
- 從ASM磁碟中複製檔案到本地檔案系統ASM
- ASM儲存使用RMAN複製控制檔案ASM
- 10G下從ASM複製檔案到檔案系統ASM
- docker檔案系統分層儲存原理Docker
- 大資料檔案儲存系統HDFS大資料
- 雲端儲存及其分散式檔案系統分散式
- 檔案系統儲存與oracle資料庫儲存對比Oracle資料庫
- xbbed一鍵讀取ASM block到檔案系統ASMBloC
- 移動資料檔案從檔案系統到ASM磁碟組中ASM
- Oracle 12C xtts and dbms_file_transferOracleTTS
- AIX儲存、LVM與檔案系統(一)AILVM
- 儲存系統實現-資料檔案格式
- ASM檔案系統遷移ASM
- asm 檔案系統遷移ASM
- 儲存文字到一個檔案裡
- 使用RMAN遷移檔案系統資料庫到ASM資料庫ASM
- 遷移檔案系統管理下的db到asm下ASM
- Oracle 10g使用DBMS_FILE_TRANSFER包在ASM和作業系統之間拷貝檔案Oracle 10gASM作業系統
- 如何複製控制檔案在ASM例項儲存ASM
- 塊儲存 檔案儲存 物件儲存物件
- [資料庫系統]儲存和檔案結構資料庫
- 【iOS資料儲存】iOS檔案系統介紹iOS
- 12c複製 RAC ASM中的密碼檔案到檔案系統ASM密碼
- 用rman從檔案系統遷移資料庫到asm資料庫ASM
- 本地儲存-系統和保留-系統檔案佔用儲存空間過大的解決方式
- 如何儲存陣列配置到 PHP 檔案陣列PHP