Oracle 12C xtts and dbms_file_transfer

eric0435發表於2018-01-17

1.初始化設定階段
1.1安裝目標資料庫軟體並建立目標資料庫
在目標系統上安裝目標Oracle資料庫軟體,版本應該為Oracle12c,作業系統是Linux,我這裡都是12.2.0.1。在源資料庫中建立了一個要被傳輸到目標資料庫的表空間jy,使用者方案jy,源資料庫版本也是12.2.0.1,作業系統是Linux。

1.2識別要被傳輸的表空間
源資料庫中要被傳輸的表空間為jy,使用者方案jy。

1.3在源系統上安裝xttconvert指令碼

[oracle@jytest3 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

 [oracle@jytest1 backup]$ vi $ORACLE_HOME/dbs/initxtt.ora
db_name=xtt
compatible=12.2.0.0.0
[oracle@jytest1 backup]$ export ORACLE_SID=xtt
[oracle@jytest1 backup]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Aug 22 18:25:46 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> startup nomount
ORACLE instance started.

Total System Global Area  444596224 bytes
Fixed Size                  8621520 bytes
Variable Size             377487920 bytes
Database Buffers           50331648 bytes
Redo Buffers                8155136 bytes

1.4 建立需要使用的目錄
如果使用dbms_file_transfer方法,那麼配置目錄物件與dblink,注意dbms_file_transfer方法要求目標資料庫的版本為11.2.0.4,如果使用dbms_file_transfer訪求,那麼必須建立以下三個資料庫物件:
.在源資料庫中建立一個資料庫目錄物件,它指向要被複制的資料檔案所存放的目錄
.在目標資料庫中建立一個資料庫目錄物件,它指向將要存放資料檔案的目錄
.在目標資料庫中建立一個dblink連線到源資料庫

源資料庫目錄物件引用源資料庫中當前存放資料檔案的目錄。例如,下面建立目錄物件指向,資料檔案存放目錄+DATA/ORCL/DATAFILE/,連線到源資料庫房執行以下命令:

[oracle@jytest3 ~]$ export ORACLE_SID=orcl
[oracle@jytest3 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Aug 21 19:57:36 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/ORCL/DATAFILE/system.280.941831569
+DATA/ORCL/DATAFILE/sysaux.281.941831647
+DATA/ORCL/DATAFILE/undotbs1.282.941831677
+DATA/ORCL/DATAFILE/users.284.941831687
+DATA/ORCL/DATAFILE/jy.371.952394755

SQL> create directory sourcedir as '+DATA/ORCL/DATAFILE';

Directory created.

目標資料庫目錄物件引用目標資料庫中將要儲存資料檔案的目錄。這個目錄是最終目標資料庫將要存放資料檔案的目錄+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/,連線到目標資料庫執行以下命令要注意的是目錄物件與dblink要在CDB中建立

[oracle@jytest1 ~]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Mon Aug 21 16:24:46 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

SQL> conn sys/abcd@jy as sysdba
Connected.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/system.274.939167015
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/sysaux.275.939167015
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/undotbs1.273.939167015
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/undo_2.277.939167063
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/testtb01.dbf
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/undotbs2.278.945029905
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/example01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/test01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/users01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/sales_test_01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/emp_test_01.dbf

NAME
--------------------------------------------------------------------------------
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/orders_test_01.dbf

12 rows selected.

SQL> create directory destdir as '+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile';

Directory created.

在目標資料庫中建立一個dblink連線到源資料庫。例如建立一個名叫ttslink的dblink,執行以下命令:

SQL> create public database link ttslink
  2    connect to system identified by "xxzx#7817600"
  3    using '(DESCRIPTION =
  4      (ADDRESS_LIST =
  5        (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.130.173)(PORT = 1521))
  6      )
  7      (CONNECT_DATA =
  8        (SERVER = DEDICATED)
  9        (SERVICE_NAME =orcl)
 10      )
 11    )';

Database link created.

SQL> select * from dual@ttslink;

D
-
X

在源系統中建立目錄/ora_xtts/backupformat用來儲存源系統中對源資料庫生成的備份及增量備份檔案,xtt.properties檔案中的backupformat引數設定該目錄。

[oracle@jytest3 ora_xtts]$ mkdir backupformat

在目標系統中建立目錄/tts/backup用來儲存手動從源系統中傳輸過來的備份及增量備份檔案,xtt.properties檔案中的stageondest引數設定該目錄。

[oracle@jytest1 tts]$ mkdir backup

xtt.properties檔案中的storageondest引數設定目標資料庫最終儲存資料檔案的目錄,這裡是

+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/目錄。

1.5在源系統中配置xtt.properties檔案

SQL> select platform_id from v$database;

PLATFORM_ID
-----------
         13


[oracle@jytest3 xtts_script]$ vi xtt.properties
tablespaces=JY
platformid=13
srcdir=SOURCEDIR
dstdir=DESTDIR
srclink=ttslink
storageondest=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/
backupformat=/ora_xtts/backupformat
stageondest=/tts/xtts
backupondest=/tts/backup
asm_home=/u01/app/product/12.2.0/crs
asm_sid=+ASM1
parallel=4
cnvinst_home=/u01/app/oracle/product/12.2.0/db
cnvinst_sid=xtt

1.6將源系統中的xttconvert指令碼與xtt.properties檔案複製到目標系統中
在源系統中以Oracle軟體使用者來進行復制

[oracle@jytest1 tts]$ scp -r oracle@10.138.130.173:/ora_xtts/xtts_script/ /tts/
The authenticity of host '10.138.130.173 (10.138.130.173)' can't be established.
ECDSA key fingerprint is 67:29:52:b1:c0:74:ff:33:fc:67:63:53:31:14:69:ec.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.173' (ECDSA) to the list of known hosts.
oracle@10.138.130.173's password:
rman_xttconvert_v3.zip                                                                                                                                                                                    100%   33KB  33.2KB/s   00:00
xttcnvrtbkupdest.sql                                                                                                                                                                                      100% 1390     1.4KB/s   00:00
xttdbopen.sql                                                                                                                                                                                             100%   71     0.1KB/s   00:00
xttdriver.pl                                                                                                                                                                                              100%  136KB 136.1KB/s   00:00
xttprep.tmpl                                                                                                                                                                                              100%   11KB  11.4KB/s   00:00
xttstartupnomount.sql                                                                                                                                                                                     100%   52     0.1KB/s   00:00
xtt.properties.jy                                                                                                                                                                                         100% 7969     7.8KB/s   00:00
xtt.properties                                                                                                                                                                                            100%  217     0.2KB/s   00:00

[oracle@jytest1 tts]$ cd xtts_script
[oracle@jytest1 xtts_script]$ ls -lrt
total 212
-rw-r--r-- 1 oracle oinstall  33949 Aug 18 23:35 rman_xttconvert_v3.zip
-rw-r--r-- 1 oracle oinstall   1390 Aug 18 23:35 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     71 Aug 18 23:35 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall 139331 Aug 18 23:35 xttdriver.pl
-rw-r--r-- 1 oracle oinstall  11710 Aug 18 23:35 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall     52 Aug 18 23:35 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall   7969 Aug 18 23:35 xtt.properties.jy
-rw-r--r-- 1 oracle oinstall    217 Aug 18 23:35 xtt.properties

1.7設定環境變數TMPDIR
在源系統與目標系統中設定環境變數TMPDIR。使用shell來執行Perl指令碼xttdriver.pl所生成的檔案會儲存在$TMPDIR目錄中,如果沒有設定TMPDIR環境變數,那麼生成的檔案會儲存在/tmp目錄中。

源系統

[oracle@jytest3 ora_xtts]$ export TMPDIR=/ora_xtts/xtts_script

目標系統

[oracle@jytest1 tts]$ export TMPDIR=/tts/xtts_script

2.準備階段
在準備階段,要被傳輸的表空間會在源系統中生成備份,然後將備份傳輸到目標系統中,並透過執行xttdriver.pl指令碼將備份還原。注意,對於要傳輸大量資料檔案,可以使用dbms_file_transfer進行傳輸(可以參考文件 1389592.1中的準備階段)會要比手動傳輸備份檔案到目標系統中快很多。這種方法也適用於Oracle 12c,11G - Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 1389592.1).

2.1在源系統中對要傳輸的表空間生成備份
在源系統中,以oracle軟體使用者登入,並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向源資料庫,執行以下命令來生成備份

[oracle@jytest3 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db
[oracle@jytest3 xtts_script]$ export ORACLE_SID=orcl

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -S
============================================================
trace file is /ora_xtts/xtts_script/setupgetfile_Aug21_Mon_20_33_36_837//Aug21_Mon_20_33_36_837_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Starting prepare phase
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'JY'  /tts/xtts
xttpreparesrc.sql for 'JY' started at Mon Aug 21 20:33:36 2017
xttpreparesrc.sql for  ended at Mon Aug 21 20:33:36 2017
Prepare source for Tablespaces:
                  ''''  /tts/xtts
xttpreparesrc.sql for '''' started at Mon Aug 21 20:33:36 2017
xttpreparesrc.sql for  ended at Mon Aug 21 20:33:36 2017

--------------------------------------------------------------------
Done with prepare phase
--------------------------------------------------------------------


[oracle@jytest3 xtts_script]$ cat xttnewdatafiles.txt
::JY
5,DESTDIR:/jy.371.952394755
[oracle@jytest3 xtts_script]$ cat getfile.sql
0,SOURCEDIR,jy.371.952394755,DESTDIR,jy_371_952394755

要被傳輸的一組表空間必須是online,read write狀態且不包含離線資料檔案。如果在源資料庫中被傳輸表空間的一個或多個資料檔案是離線狀態或read only就會觸發錯誤。如果表空間在整個表空間傳輸過程中都保持read only狀態,那麼就使用傳統的跨平臺傳輸表空間,不要使用跨平臺增量備份傳輸表空間。

2.2 傳輸資料檔案到目標系統中
在目標系統中,使用Oracle軟體使用者登入並設定相關環境變數(ORACLE_HOME與ORACLE_SID)來指向目標資料庫,並複製上一步生成的xttnewdatafiles.txt與getfile.sql檔案到目標系統並執行操作來獲取資料檔案

[oracle@jytest1 xtts_script]$ scp oracle@10.138.130.173:/ora_xtts/xtts_script/xttnewdatafiles.txt /tts/xtts_script/
oracle@10.138.130.173's password:
xttnewdatafiles.txt                                                                                                                                                                                       100%   33     0.0KB/s   00:00
[oracle@jytest1 xtts_script]$ scp oracle@10.138.130.173:/ora_xtts/xtts_script/getfile.sql    /tts/xtts_script/
oracle@10.138.130.173's password:
getfile.sql                                                                                                                                                                                               100%   54     0.1KB/s   00:00
[oracle@jytest1 xtts_script]$ ls -lrt
total 220
-rw-r--r-- 1 oracle oinstall   1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     52 May 24 16:57 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall  11710 May 24 16:57 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall 139331 May 24 16:57 xttdriver.pl
-rw-r--r-- 1 oracle oinstall     71 May 24 16:57 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall   7969 Jun  5 08:47 xtt.properties.jy
-rw-r--r-- 1 oracle oinstall  33949 Aug 18 23:35 rman_xttconvert_v3.zip
-rw-r--r-- 1 oracle oinstall    351 Aug 21 17:02 xtt.properties
-rw-r--r-- 1 oracle oinstall     33 Aug 21 17:17 xttnewdatafiles.txt
-rw-r--r-- 1 oracle oinstall     54 Aug 21 17:17 getfile.sql

[oracle@jytest1 xtts_script]$ export TMPDIR=/tts/xtts_script
[oracle@jytest1 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db
[oracle@jytest1 xtts_script]$ export ORACLE_SID=jy1
[oracle@jytest1 xtts_script]$ export XTTDEBUG=1
[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G
============================================================
trace file is /tts/xtts_script/getfile_Aug22_Tue_17_28_19_991//Aug22_Tue_17_28_19_991_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: backupondest
Values: /tts/backup
Key: backupformat
Values: /ora_xtts/backupformat
Key: cnvinst_sid
Values: jy1
Key: asm_sid
Values: +ASM1
Key: stageondest
Values: /tts/xtts
Key: srclink
Values: ttslink
Key: parallel
Values: 4
Key: tablespaces
Values: JY
Key: platformid
Values: 13
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: dstdir
Values: DESTDIR
Key: srcdir
Values: SOURCEDIR
Key: storageondest
Values: +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT srcdir
ARGUMENT dstdir
ARGUMENT srclink

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Getting datafiles from source
--------------------------------------------------------------------

fetchCheckDirObjectsDST: Check dir path

fetchDirEntry: remotelink not present


--------------------------------------------------------------------
Executing getfile for /tts/xtts_script/getfile_Aug22_Tue_17_28_19_991//getfile_sourcedir_jy.371.952394755_0.sql
--------------------------------------------------------------------

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
Completed getting datafiles from source
--------------------------------------------------------------------

3.前滾階段
下面在源資料庫中建立增量資料

SQL> select * from jy.jy_test;

   USER_ID
----------
         1
         2
         3
SQL> insert into jy.jy_test values(4);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from jy.jy_test;

   USER_ID
----------
         1
         2
         3
         4

在這個階段會在源系統中對源資料庫建立增量備份,將增量備份檔案傳輸到目標系統並轉換為目標系統所使用的位元組序,然後將轉換後的增量備份應用到資料檔案。這個階段的操作可以執行多次。每一次成功的增量備份所花的時間要比上一次的少,這將使用目標資料庫中的資料檔案的內容更接近源資料庫的內容。在執行這個階段操作時被傳輸的資料完全可以被訪問。

3.1 在源系統中對被傳輸的表空間LDJC,CDZJ建立增量備份
在源系統中,以Oracle軟體使用者登入並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向源資料庫,並執行以下命令來建立增量備份:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /ora_xtts/xtts_script/incremental_Aug22_Tue_21_19_39_709//Aug22_Tue_21_19_39_709_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: srclink
Values: ttslink
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: platformid
Values: 13
Key: storageondest
Values: +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: backupondest
Values: /tts/backup
Key: srcdir
Values: SOURCEDIR
Key: cnvinst_sid
Values: jy1
Key: tablespaces
Values: JY
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: backupformat
Values: /ora_xtts/backupformat
Key: parallel
Values: 4
Key: stageondest
Values: /tts/xtts

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : orcl
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

fetchCheckDirObjectsSRC: Check dir path

fetchDirEntry: remotelink not present

TABLESPACE STRING :'JY'
Prepare source for Tablespaces:
                  'JY'  /tts/xtts
xttpreparesrc.sql for 'JY' started at Tue Aug 22 21:19:39 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:19:39 2017
#DNAME:+DATA/ORCL/DATAFILE
#FNAME:jy.371.952394755
#PLAN:JY::::62924193
#TRANSFER:source_file_name=JY,+DATA/ORCL/DATAFILE,jy.371.952394755
#NEWDESTDF:5,DESTDIR:+DATA/ORCL/DATAFILE,/jy.371.952394755
#PLAN:5
verifySrcdirDatafiles: Entered
TABLESPACE STRING :''''
Prepare source for Tablespaces:
                  ''''  /tts/xtts
xttpreparesrc.sql for '''' started at Tue Aug 22 21:19:39 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:19:40 2017

verifySrcdirDatafiles: Entered
JY: +DATA/ORCL/DATAFILE/jy.371.952394755

============================================================
No new datafiles added
=============================================================
TABLESPACE STRING :'JY'
Prepare newscn for Tablespaces: 'JY'
JY::::62924193
 5
TABLESPACE STRING :''''''
Prepare newscn for Tablespaces: ''''''


--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------

/ora_xtts/xtts_script/incremental_Aug22_Tue_21_19_39_709//rmanincr.cmd

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Aug 22 21:19:40 2017

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

RMAN-06005: connected to target database: ORCL (DBID=1469612247)

RMAN> set nocfau;
2> host 'echo ts::JY';
3> backup incremental from scn 62924193
4>   tag tts_incr_update tablespace 'JY'  format
5>  '/ora_xtts/backupformat/%U';
6>
RMAN-03023: executing command: SET NOCFAU
RMAN-06009: using target database control file instead of recovery catalog

ts::JY
RMAN-06134: host command complete

RMAN-03090: Starting backup at 22-AUG-17
RMAN-08030: allocated channel: ORA_DISK_1
RMAN-08500: channel ORA_DISK_1: SID=43 device type=DISK
RMAN-08008: channel ORA_DISK_1: starting full datafile backup set
RMAN-08010: channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-08522: input datafile file number=00005 name=+DATA/ORCL/DATAFILE/jy.371.952394755
RMAN-08038: channel ORA_DISK_1: starting piece 1 at 22-AUG-17
RMAN-08044: channel ORA_DISK_1: finished piece 1 at 22-AUG-17
RMAN-08530: piece handle=/ora_xtts/backupformat/2dscipng_1_1 tag=TTS_INCR_UPDATE comment=NONE
RMAN-08540: channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
RMAN-03091: Finished backup at 22-AUG-17

Recovery Manager complete.


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作會執行RMAN命令對xtt.properties檔案中所指定的所有表空間生成增量備份檔案。並且還將建立以下檔案供後面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的內容如下:

[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=2dscipng_1_1

檔案中的內容記錄了表空間與增量備份的關聯關係

incrbackups.txt的內容如下:

[oracle@jytest3 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/2dscipng_1_1

檔案中的內容顯示了生成的增量備份檔案資訊

[oracle@jytest3 backupformat]$ ls -lrt
total 56
-rw-r-----. 1 oracle asmadmin 57344 Aug 22 21:19 2dscipng_1_1

3.2 將增量備份傳輸到目標系統中
將上一步生成的增量備份傳輸到目標系統中由xtt.properties檔案中的stageondest目錄(/oracle11/xtts)中。

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/xtts/
oracle@10.138.130.171's password:
2dscipng_1_1
                                                                                                                                                                               100%   56KB  56.0KB/s   00:00

3.3 在目標系統中轉換增量備份並應用到資料檔案副本
在目標系統中以Oracle軟體使用者登入並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向目標資料庫,並從源系統中將上一步生成的xttplan.txt與tsbkupmap.txt檔案。

[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttplan.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttplan.txt                                                                                                                                                                                               100%   17     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   23     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/incrbackups.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
incrbackups.txt                                                                                                                                                                                           100%   36     0.0KB/s   00:00


[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /tts/xtts_script/rollforward_Aug22_Tue_18_27_05_399//Aug22_Tue_18_27_05_399_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupformat
Values: /ora_xtts/backupformat
Key: srclink
Values: ttslink
Key: tablespaces
Values: JY
Key: parallel
Values: 4
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: cnvinst_sid
Values: xtt
Key: platformid
Values: 13
Key: stageondest
Values: /tts/xtts
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: backupondest
Values: /tts/backup
Key: srcdir
Values: SOURCEDIR

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /u01/app/oracle/product/12.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 6442450944 bytes
Fixed Size                  8807168 bytes
Variable Size            3909094656 bytes
Database Buffers         1442840576 bytes
Redo Buffers                7966720 bytes
In-Memory Area           1073741824 bytes
rdfno 5

BEFORE ROLLPLAN

datafile number : 5

datafile name   : +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/tts/backup/xib_2dscipng_1_1_5

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm /tts/backup/xib_2dscipng_1_1_5  /u01/app/product/12.2.0/crs .. +ASM1

Connected to an idle instance.
ASMCMD-8102: no connection to Oracle ASM; command requires Oracle ASM to run
ASMCMD:


--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

這步前滾資料檔案的操作,會以sys使用者連線到增量轉換例項,轉換完增量備份後,然後連線到目標資料庫並將增量備份應用到每個表空間注意:對於每一次增量備份都需要將xttplan.txt與tsbkupmap.txt檔案複製一次,不要對指令碼所生成的xttplan.txt.new檔案進行修改,複製或者其它任何改變。執行這步操作時目標例項會進行重啟操作。

3.4 為下一次增量備份判斷from_scn
再次生成增量資料

SQL> insert into jy.jy_test values(5);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from jy.jy_test;

   USER_ID
----------
         1
         2
         3
         4
         5

在源系統中,以Oracle軟體使用者登入並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向源資料庫,執行以下命令來判斷from_scn:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /ora_xtts/xtts_script/determinescn_Aug22_Tue_21_54_18_326//Aug22_Tue_21_54_18_326_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupformat
Values: /ora_xtts/backupformat
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: tablespaces
Values: JY
Key: platformid
Values: 13
Key: stageondest
Values: /tts/xtts
Key: backupondest
Values: /tts/backup
Key: parallel
Values: 4
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: srcdir
Values: SOURCEDIR
Key: dstdir
Values: DESTDIR
Key: asm_sid
Values: +ASM1
Key: cnvinst_sid
Values: xtt
Key: srclink
Values: ttslink

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : orcl
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db
TABLESPACE STRING :'JY'
Prepare newscn for Tablespaces: 'JY'

TABLESPACE STRING :''''
Prepare newscn for Tablespaces: ''''

New /ora_xtts/xtts_script/xttplan.txt with FROM SCN's generated


New /ora_xtts/xtts_script/xttplan.txt with FROM SCN's generated
[oracle@jytest3 xtts_script]$ cat xttplan.txt
 JY::::62924193
 5

4.傳輸階段
在執行傳輸階段操作時,源資料庫中被傳輸表空間要設定為read only狀態,並且透過建立與應用最後一次的增量備份使用目標資料庫中的資料檔案與源資料庫中的資料檔案內容保持一致。在目標資料庫資料檔案與源資料庫資料檔案內容達成一致後,在源系統中執行正常的傳輸表空間操作來匯出後設資料,然後將後設資料匯入到目標資料庫中。直到傳輸階段操作完成之前,被傳輸的資料只能以read only模式被訪問。

4.1 將源資料庫中被傳輸表空間設定為read only狀態
在源系統中,以Oracle軟體使用者登入並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向源資料庫,並執行以下命令將表空間設定為read only:

SQL> alter tablespace jy read only;

Tablespace altered.

4.2 最後一次建立增量備份,並傳輸到目標系統且執行轉換並應用到目標資料檔案
在源系統中,以Oracle軟體使用者登入並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向源資料庫,並執行以下命令來建立增量備份:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /ora_xtts/xtts_script/incremental_Aug22_Tue_21_57_21_478//Aug22_Tue_21_57_21_478_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: parallel
Values: 4
Key: backupformat
Values: /ora_xtts/backupformat
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: platformid
Values: 13
Key: tablespaces
Values: JY
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: stageondest
Values: /tts/xtts
Key: srclink
Values: ttslink
Key: srcdir
Values: SOURCEDIR
Key: backupondest
Values: /tts/backup
Key: dstdir
Values: DESTDIR
Key: asm_sid
Values: +ASM1
Key: cnvinst_sid
Values: xtt

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : orcl
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

fetchCheckDirObjectsSRC: Check dir path

fetchDirEntry: remotelink not present

TABLESPACE STRING :'JY'
Prepare source for Tablespaces:
                  'JY'  /tts/xtts
xttpreparesrc.sql for 'JY' started at Tue Aug 22 21:57:21 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:57:21 2017
#DNAME:+DATA/ORCL/DATAFILE
#FNAME:jy.371.952394755
#PLAN:JY::::62928997
#TRANSFER:source_file_name=JY,+DATA/ORCL/DATAFILE,jy.371.952394755
#NEWDESTDF:5,DESTDIR:+DATA/ORCL/DATAFILE,/jy.371.952394755
#PLAN:5
verifySrcdirDatafiles: Entered
TABLESPACE STRING :''''
Prepare source for Tablespaces:
                  ''''  /tts/xtts
xttpreparesrc.sql for '''' started at Tue Aug 22 21:57:21 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:57:21 2017

verifySrcdirDatafiles: Entered
JY: +DATA/ORCL/DATAFILE/jy.371.952394755

============================================================
No new datafiles added
=============================================================
TABLESPACE STRING :'JY'
Prepare newscn for Tablespaces: 'JY'
JY::::62928997
 5
TABLESPACE STRING :''''''
Prepare newscn for Tablespaces: ''''''


--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------

/ora_xtts/xtts_script/incremental_Aug22_Tue_21_57_21_478//rmanincr.cmd

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Aug 22 21:57:21 2017

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

RMAN-06005: connected to target database: ORCL (DBID=1469612247)

RMAN> set nocfau;
2> host 'echo ts::JY';
3> backup incremental from scn 62924193
4>   tag tts_incr_update tablespace 'JY'  format
5>  '/ora_xtts/backupformat/%U';
6>
RMAN-03023: executing command: SET NOCFAU
RMAN-06009: using target database control file instead of recovery catalog

ts::JY
RMAN-06134: host command complete

RMAN-03090: Starting backup at 22-AUG-17
RMAN-08030: allocated channel: ORA_DISK_1
RMAN-08500: channel ORA_DISK_1: SID=43 device type=DISK
RMAN-08008: channel ORA_DISK_1: starting full datafile backup set
RMAN-08010: channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-08522: input datafile file number=00005 name=+DATA/ORCL/DATAFILE/jy.371.952394755
RMAN-08038: channel ORA_DISK_1: starting piece 1 at 22-AUG-17
RMAN-08044: channel ORA_DISK_1: finished piece 1 at 22-AUG-17
RMAN-08530: piece handle=/ora_xtts/backupformat/2esciru5_1_1 tag=TTS_INCR_UPDATE comment=NONE
RMAN-08540: channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
RMAN-03091: Finished backup at 22-AUG-17

Recovery Manager complete.


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作會執行RMAN命令對xtt.properties檔案中所指定的所有表空間生成增量備份檔案。並且還將建立以下檔案供後面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的內容如下:

[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=2esciru5_1_1

檔案中的內容記錄了表空間與增量備份的關聯關係

incrbackups.txt的內容如下:

[oracle@jytest3 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/2esciru5_1_1

檔案中的內容顯示了生成的增量備份檔案資訊

[oracle@jytest3 backupformat]$ ls -lrt
total 112
-rw-r-----. 1 oracle asmadmin 57344 Aug 22 21:19 2dscipng_1_1
-rw-r-----. 1 oracle asmadmin 57344 Aug 22 21:57 2esciru5_1_1

將增量備份傳輸到目標系統中
將上一步生成的增量備份傳輸到目標系統中由xtt.properties檔案中的stageondest目錄(/oracle11/xtts)中。

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/xtts/
oracle@10.138.130.171's password:
2dscipng_1_1
                                                                                                                                                                               100%   56KB  56.0KB/s   00:00

在目標系統中轉換增量備份並應用到資料檔案副本
在目標系統中以Oracle軟體使用者登入並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向目標資料庫,並從源系統中將上一步生成的xttplan.txt與tsbkupmap.txt檔案。

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/xtts/
oracle@10.138.130.171's password:
2esciru5_1_1                                                                                                                                                                                              100%   56KB  56.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttplan.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttplan.txt                                                                                                                                                                                               100%   19     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   23     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/incrbackups.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
incrbackups.txt                                                                                                                                                                                           100%   36     0.0KB/s   00:00

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /tts/xtts_script/rollforward_Aug22_Tue_18_38_06_743//Aug22_Tue_18_38_06_743_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: dstdir
Values: DESTDIR
Key: stageondest
Values: /tts/xtts
Key: platformid
Values: 13
Key: parallel
Values: 4
Key: backupformat
Values: /ora_xtts/backupformat
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: cnvinst_sid
Values: xtt
Key: srclink
Values: ttslink
Key: srcdir
Values: SOURCEDIR
Key: asm_sid
Values: +ASM1
Key: tablespaces
Values: JY
Key: backupondest
Values: /tts/backup

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /u01/app/oracle/product/12.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 6442450944 bytes
Fixed Size                  8807168 bytes
Variable Size            3892317440 bytes
Database Buffers         1459617792 bytes
Redo Buffers                7966720 bytes
In-Memory Area           1073741824 bytes
rdfno 5

BEFORE ROLLPLAN

datafile number : 5

datafile name   : +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/tts/backup/xib_2esciru5_1_1_5

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm /tts/backup/xib_2esciru5_1_1_5  /u01/app/product/12.2.0/crs .. +ASM1

Connected to an idle instance.
ASMCMD-8102: no connection to Oracle ASM; command requires Oracle ASM to run
ASMCMD:


--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

4.3 在目標資料庫中匯入後設資料
在目標系統中以Oracle軟體使用者登入並設定環境變數(ORACLE_HOME與ORACLE_SID)來指向目標資料庫,執行以下命令來生成Data Pump TTS命令:

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -e
============================================================
trace file is /tts/xtts_script/generate_Aug22_Tue_18_39_22_670//Aug22_Tue_18_39_22_670_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: cnvinst_sid
Values: xtt
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: platformid
Values: 13
Key: backupondest
Values: /tts/backup
Key: parallel
Values: 4
Key: stageondest
Values: /tts/xtts
Key: tablespaces
Values: JY
Key: srclink
Values: ttslink
Key: srcdir
Values: SOURCEDIR
Key: backupformat
Values: /ora_xtts/backupformat
Key: asm_home
Values: /u01/app/product/12.2.0/crs

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Generating plugin
--------------------------------------------------------------------


--------------------------------------------------------------------
Done generating plugin file /tts/xtts_script/xttplugin.txt
--------------------------------------------------------------------

[oracle@jytest1 xtts_script]$ cat xttplugin.txt
impdp directory= logfile= \
network_link= transport_full_check=no \
transport_tablespaces=JY \
transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755'

上面的命令會生成一個名叫xttplugin.txt的檔案,檔案建立了一個使用network_link引數執行傳輸表空間匯入後設資料的命令。命令中的transport_tablespaces與transport_datafiles引數已經設定正確。注意network_link模式指示匯入透過使用dblink來完成,就不需要執行匯出或使用dump檔案。如果選擇執行這個命令來完成表空間的傳輸就需要修改directory,logfile與network_link引數

SQL> create directory dump_dir as '/tts/xtts_script';

Directory created.
SQL> grant read,write on directory dump_dir to public;

Grant succeeded.


在目標資料庫中建立使用者方案jy

SQL> create user jy identified by "jy";

User created.

SQL> grant dba,connect,resource to jy;

Grant succeeded.

[oracle@jytest1 xtts_script]$ impdp  system/abcd@jypdb directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=JY transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755'

Import: Release 12.2.0.1.0 - Production on Tue Aug 22 18:45:00 2017

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

Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03":  system/********@jypdb directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=JY transport_datafiles=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755
Source time zone is +08:00 and target time zone is +00:00.
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03" successfully completed at Tue Aug 22 18:46:20 2017 elapsed 0 00:01:11


[oracle@jytest1 xtts_script]$ impdp system/abcd@jypdb directory=dump_dir logfile=ysj.log  content=metadata_only exclude=table,index network_link=ttslink

Import: Release 12.2.0.1.0 - Production on Tue Aug 22 18:47:22 2017

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

Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/********@jypdb directory=dump_dir logfile=ysj.log content=metadata_only exclude=table,index network_link=ttslink
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/STATISTICS/MARKER
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully completed at Tue Aug 22 18:47:49 2017 elapsed 0 00:00:21

5.驗證傳輸資料
5.1檢查表空間是否有損壞

[oracle@jytest1 xtts_script]$ rman target sys/abcd@jypdb

Recovery Manager: Release 12.2.0.1.0 - Production on Sat Aug 19 01:17:35 2017

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

connected to target database: JY:JYPDB (DBID=2825277312)

RMAN> validate tablespace jy check logical;

Starting validate at 19-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1144 instance=jy1 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00083 name=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_5.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:07
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
83   OK     0              1            64001           1590987
  File Name: +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_5.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              5
  Index      0              0
  Other      0              63994

Finished validate at 19-AUG-17

5.2將目標資料庫中的表空間JY修改為read write狀態

SQL> alter tablespace jy read write;

Tablespace altered.

6.清除操作
如果使用單獨的轉換home與例項,那麼可以關閉轉換例項並刪除轉換home。還可以刪除源系統中建立的backupformat目錄,目標系統中建立的bacup目錄,源系統與目標系統中設定的環境變數$TMPDIR。

xttdriver.pl指令碼選項
--backup:對源資料庫中要被傳輸的表空間建立level 0級備份。這些備份將被寫到xtt.properties檔案中backupoformat引數所指定的目錄中。這些備份需要手動複製到目標系統中stageondest引數所指定的目錄中。而且還會生成tsbkupmap.txt與xttnewdatafiles.txt檔案並且也需要複製到目標系統中相應目錄(TMPDIR變數所指向的目錄)

--restore:在目標系統中還原並轉換stageondest目錄中的資料檔案備份的副本。還原的檔案將會儲存到storageondest引數所指定的目錄中

--bkpincr:在源系統中對錶空間建立增量備份並儲存在backupformat引數所指定的目錄中。這步操作還會建立incrbackups.txt檔案它列出了所建立的備份。這個檔案與tsbkupmap.txt必須複製到目標系統中的stageondest引數所指定的目錄中

-recover:將增量備份應用到已經還原的資料檔案上

-s:對源資料庫判斷新的from_scn可以執行一次或多次。這個操作將會計算下一個from_scn,並記錄在xttplan.txt檔案中,然後使用建立增量備份時會使用。

-bkpexport:將執行最後一次增量備份並且會建立後設資料的dump檔案用來匯入資料檔案。增量備份將會儲存在backupformat引數所指定的目錄中並且會建立incrbckups.txt與tsbkupmaps.txt檔案,這些都要複製到目標系統中

--resincrdmp:將恢復最後一次增量備份並應用到資料檔案。同時dump檔案會被還原到TMPDIR變數所指定的目錄中,dump檔案可以用來匯入

-e:在目標系統中生成傳輸表空間要匯入的後設資料指令碼

-d debug:為了以debug模式來執行xttdriver.pl 與RMAN指令碼。也可以設定環境變數XTTDEBUG=1,debug級別可以為1,2,3,例如xttdriver.pl -3

xtt.properties檔案引數說明
tablespaces:用逗號來分隔從源資料庫要被傳輸到目標資料庫的表空間列表,例如tablespaces=TS1,TS2

platformid:從v$database.platform_id獲得的源資料庫的platform id,例如platformid=13

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

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2150223/,如需轉載,請註明出處,否則將追究法律責任。

相關文章