1. 程式人生 > >利用DBMS_FILE_TRANSFER遷移數據庫從AIX至Linux

利用DBMS_FILE_TRANSFER遷移數據庫從AIX至Linux

xtts dbms_file_transfer aix linux

環境描述


源端

目標端

操作系統

AIX 6100-03-10-1119

RHEL6.5 x64

集群

Oracle RAC+ASM

Oracle RAC+ASM

數據庫版本

11.2.0.3.0

11.2.0.4.0

1、初始化階段

1.1、源端數據庫

源端數據庫testdb,數據庫版本11.2.0.3.0,運行在AIX 64-bit

db1:/oracle/db/bin$echo $ORACLE_SID

testdb1

db1:/oracle/db/bin$echo $ORACLE_HOME

/oracle/db

SYS@testdb1 > select * from v$version where banner like‘%Database%‘;

BANNER

-------------------------------------------------------------------------------

Oracle Database 11g Enterprise EditionRelease 11.2.0.3.0 - 64bit Production

SYS@testdb1 > select name, platform_id, platform_name fromv$database;

NAME PLATFORM_IDPLATFORM_NAME

--------------------------- ----------- ------------------------------

TESTDB 6 AIX-BasedSystems (64-bit)

需要進行遷移的表空間為XTTSTEST:

select t.name "Tablespace", f.file# "File#",f.name "Filename", f.status "Status"

from v$datafile f, v$tablespace t

where f.ts#=t.ts# and t.name like ‘XTTS%‘

order by 1, 2;

Tablespace File# Filename Status

---------- ------------------------------------------------------------ -------

XTTSTEST 41 +ORADATA/testdb/datafile/xttstest.362.959887907 ONLINE

SYS@testdb1 >

在源端為DBMS_FILE_TRANSFER創建目錄SOURCEDIR,其路徑為遷移表空間數據文件路徑

SYS@testdb1 > create directory sourcedir as ‘+ORADATA/testdb/datafile‘;

Directory created.

源端數據庫必須為歸檔模式

SYS@testdb1 > archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence 11771

Next log sequence to archive 11775

Current log sequence 11775

如下為oracle用戶設置TMPDR環境變量

export TMPDIR=/home/oracle/tts

上傳rman-xttconvert_2.0.zip至/home/oracle/tts目錄並解壓

db1:/home/oracle/tts$unzip rman-xttconvert_2.0.zip

Archive: rman-xttconvert_2.0.zip

inflating: xttcnvrtbkupdest.sql

inflating: xttdbopen.sql

inflating: xttdriver.pl

inflating: xttprep.tmpl

inflating: xtt.properties

inflating: xttstartupnomount.sql

對xtt.properties文件進行如下配置

db1:/home/oracle/tts$grep ^[a-z] xtt.properties

tablespaces=XTTSTEST

platformid=6

srcdir=SOURCEDIR

dstdir=DESTDIR

srclink=TTSLINK

dfcopydir=/home/oracle/stage_source

backupformat=/home/oracle/stage_source

stageondest=/home/oracle/stage_dest

backupondest=+FRA_SB

asm_home=/testdb/orgrid/oracle/product/112

asm_sid=+ASM1

xtt.properties文件裏的大部分參數都有說明,可以參照說明進行配置。需要註意的是platformid必須設置成源端數據庫platform id,platform id可以從v$database查詢到。

xtt.properties在源端配置完成後,拷貝到目標端:

db1:/home/oracle$scp -r tts x.x.x.81:/home/oracle

[email protected]‘s password:

rman-xttconvert_2.0.zip 100% 26KB 26.3KB/s 00:00

xtt.properties 100% 7820 7.6KB/s 00:00

xttcnvrtbkupdest.sql 100% 1390 1.4KB/s 00:00

xttdbopen.sql 100% 71 0.1KB/s 00:00

xttdriver.pl 100% 90KB 89.6KB/s 00:00

xttprep.tmpl 100% 11KB 11.3KB/s 00:00

xttstartupnomount.sql 100% 52 0.1KB/s 00:00

在源端和目標端創建xtt.properties文件參數配置的目錄

1.2、目標端數據庫

源端數據庫testdb,數據庫版本11.2.0.4.0,運行在Linux x86 64-bit

[oracle@testdb1 ~]$ env | egrep "ORACLE_SID|ORACLE_HOME"

ORACLE_SID=testdb1

ORACLE_HOME=/testdb/ordb/oracle/product/112

SQL> select * from v$version where banner like ‘%Database%‘;

BANNER

-------------------------------------------------------------------------------

Oracle Database 11g Enterprise EditionRelease 11.2.0.4.0 - 64bit Production

SQL> select name, platform_id, platform_name from v$database;

NAME PLATFORM_ID PLATFORM_NAME

--------- ----------- --------------------

TESTDB 13 Linux x86 64-bit

需要註意的是源端數據庫和目標端數據庫字符集必須一致。

源端:

SYS@testdb1 > select PARAMETER, VALUE

2 from v$nls_parameters

3 where PARAMETER in (‘NLS_CHARACTERSET‘,‘NLS_NCHAR_CHARACTERSET‘);

PARAMETER VALUE

--------------------------------------------------

NLS_CHARACTERSET ZHS16GBK

NLS_NCHAR_CHARACTERSET UTF8

目標端:

SQL> select PARAMETER, VALUE

2 from v$nls_parameters

3 where PARAMETER in (‘NLS_CHARACTERSET‘,‘NLS_NCHAR_CHARACTERSET‘);

PARAMETER VALUE

------------------------------------------------------------

NLS_CHARACTERSET ZHS16GBK

NLS_NCHAR_CHARACTERSET UTF8

在目標端創建到源端的database link TTSLINK:

SQL> create public database link ttslink connect to systemidentified by oracle_test using ‘source‘;

Database link created.

SQL> select * from dual@ttslink;

D

-

X

在目標端為DBMS_FILE_TRANSFER創建目錄DESTDIR,其路徑為目標端數據庫數據文件路徑

SQL> create directory destdir as ‘+DATA_SB/dest/datafile‘;

Directory created.

SQL>

如下為oracle用戶設置TMPDR環境變量

export TMPDIR=/home/oracle/tts

2、數據文件傳輸階段

本階段XTTSTEST表空間的數據文件將從源端數據庫傳輸到目標端數據庫,字節轉換由DBMS_FILE_TRANSFER包自動完成,本步驟只需要執行一次,數據文件傳輸過程中不影響源端數據庫正常訪問。

在源端以oracle用戶登錄,並設置數據庫和TMPDIR變量。

2.1. 源端創建傳輸腳本

運行 ‘perl xttdriver.pl -S‘:

db1:/home/oracle$cd $TMPDIR

db1:/home/oracle/tts$$ORACLE_HOME/perl/bin/perl xttdriver.pl -S

--------------------------------------------------------------------

Parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Starting prepare phase

--------------------------------------------------------------------

Prepare source for Tablespaces:

‘XTTSTEST‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘XTTSTEST‘ started atMon Nov 13 15:00:39 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:39 2017

Prepare source for Tablespaces:

‘‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘‘ started at Mon Nov13 15:00:39 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:39 2017

Prepare source for Tablespaces:

‘‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘‘ started at Mon Nov13 15:00:39 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:39 2017

Prepare source for Tablespaces:

‘‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘‘ started at Mon Nov13 15:00:39 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:39 2017

Prepare source for Tablespaces:

‘‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘‘ started at Mon Nov13 15:00:39 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:40 2017

Prepare source for Tablespaces:

‘‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘‘ started at Mon Nov13 15:00:40 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:40 2017

Prepare source for Tablespaces:

‘‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘‘ started at Mon Nov13 15:00:40 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:40 2017

Prepare source for Tablespaces:

‘‘ /home/oracle/stage_dest

xttpreparesrc.sql for ‘‘ started at Mon Nov13 15:00:40 2017

xttpreparesrc.sql for ended at Mon Nov 13 15:00:40 2017

--------------------------------------------------------------------

Done with prepare phase

--------------------------------------------------------------------

本步驟將在當前目錄(TMPDIR)生成如下文件

1. xttplan.txt - containing the tablespacenames, their current SCNs and their datafile numbers:

db1:/home/oracle/tts$cat xttplan.txt

XTTSTEST::::15718791765461

41

2. xttnewdatafiles.txt - containing thetablespace names, datafile numbers, the destination directory object name and thesource filenames:

db1:/home/oracle/tts$catxttnewdatafiles.txt

::XTTSTEST

41,DESTDIR:/xttstest.362.959887907

3. getfile.sql - The PL/SQL script(formatting ours) that will be used at the destination to get the datafilesfrom the source:

db1:/home/oracle/tts$cat getfile.sql

0,SOURCEDIR,xttstest.362.959887907,DESTDIR,xttstest_362_959887907

4. xttpreparesrc.sql - the PL/SQL scriptused to create the files in this step.

5. xttprepareNaNd - the command script(empty at this step).

2.2. 傳輸數據文件到目標端

在目標端以oracle用戶登錄,並設置環境變量。

[oracle@testdb1 ~]$ env | egrep "ORACLE_SID|ORACLE_HOME"

ORACLE_SID=dest1

ORACLE_HOME=/testdb/ordb/oracle/product/112

從源端拷貝xttnewdatafiles.txt 和 getfile.sql到目標端

[oracle@testdb1 tts]$ scp x.x.x.3:/home/oracle/tts/xttnewdatafiles.txt.

The authenticity of host ‘x.x.x.3 (x.x.x.3)‘can‘t be established.

RSA key fingerprint is33:f6:00:32:8c:5d:3e:44:5f:1b:e1:61:40:c4:2d:c1.

Are you sure you want to continueconnecting (yes/no)? yes

Warning: Permanently added ‘x.x.x.3‘ (RSA)to the list of known hosts.

[email protected]‘s password:

xttnewdatafiles.txt 100% 46 0.0KB/s 00:00

[oracle@testdb1 tts]$ ls

rman-xttconvert_2.0.zip xttdbopen.sql xttnewdatafiles.txt xtt.properties

xttcnvrtbkupdest.sql xttdriver.pl xttprep.tmpl xttstartupnomount.sql

[oracle@testdb1 tts]$ ll

total 156

-rw-r----- 1 oracle oinstall 26975 Nov 1315:03 rman-xttconvert_2.0.zip

-rwxr-xr-x 1 oracle oinstall 1390 Nov 13 15:03 xttcnvrtbkupdest.sql

-rwxr-xr-x 1 oracle oinstall 71 Nov 13 15:03 xttdbopen.sql

-rwxr-xr-x 1 oracle oinstall 91722 Nov 1315:03 xttdriver.pl

-rw-r--r-- 1 oracle oinstall 46 Nov 13 15:21 xttnewdatafiles.txt

-rwxr-xr-x 1 oracle oinstall 11549 Nov 1315:03 xttprep.tmpl

-rwxr-xr-x 1 oracle oinstall 7820 Nov 13 15:03 xtt.properties

-rwxr-xr-x 1 oracle oinstall 52 Nov 13 15:03 xttstartupnomount.sql

[oracle@testdb1 tts]$ scp x.x.x.3:/home/oracle/tts/getfile.sql .

[email protected]‘s password:

getfile.sql 100% 66 0.1KB/s 00:01

在目標端通過執行‘xttdriver.pl -G‘進行數據文件傳輸

[oracle@testdb1 tts]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G

--------------------------------------------------------------------

Parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Getting datafiles from source

--------------------------------------------------------------------

sh: line 5: warning: here-document at line0 delimited by end-of-file (wanted `EOF‘)

sh: line 6: warning: here-document at line0 delimited by end-of-file (wanted `EOF‘)

--------------------------------------------------------------------

Executing getfile forgetfile_sourcedir_xttstest.362.959887907_0.sql

--------------------------------------------------------------------

--------------------------------------------------------------------

Completed getting datafiles from source

--------------------------------------------------------------------

本步驟不產生任何輸出。本步驟將花費數據庫遷移的大部分時間,因為本步驟會傳輸源端的數據文件到目標端。

本步驟執行完成,可以在目標端數據庫數據文件存儲目錄發現從源端傳輸過來的數據文件。

ASMCMD> ls

FILE_TRANSFER.339.959959381

SYSAUX.259.959957695

SYSTEM.303.959957695

UNDOTBS1.264.959957697

UNDOTBS2.335.959957845

USERS.256.959957697

xttstest_362_959887907

3. 增量更新備份階段

增量更新備份是通過RMAN增量備份來實現的。不過該階段增量備份是通過DBMS_FILE_TRANSFER.GET_FILE來實現的,而不是RMANBACKUP AS COPY。本階段增量備份在源端數據庫創建,然後傳輸到目標端數據庫,最後與第二階段傳輸過來的數據文件進行合並。

這個階段中的步驟可以運行多次,以使目標中的datafiles更接近源文件的時間/ SCN。在此階段,源數據庫完全可訪問。

3.1. 源端數據庫創建增量備份

在源端數據庫以oracle用戶登錄,並設置環境變量,執行‘xttdriver.pl -i‘:

db1:/home/oracle/tts$$ORACLE_HOME/perl/bin/perl xttdriver.pl -i

--------------------------------------------------------------------

Parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Backup incremental

--------------------------------------------------------------------

Prepare newscn for Tablespaces: ‘XTTSTEST‘

Prepare newscn for Tablespaces: ‘‘

Prepare newscn for Tablespaces: ‘‘

Prepare newscn for Tablespaces: ‘‘

Prepare newscn for Tablespaces: ‘‘

Prepare newscn for Tablespaces: ‘‘

Prepare newscn for Tablespaces: ‘‘

Prepare newscn for Tablespaces: ‘‘

rman target / cmdfile /home/oracle/tts/rmanincrNaNd

Recovery Manager: Release 11.2.0.3.0 -Production on Mon Nov 13 15:14:31 2017

Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.

connected to target database: TESTDB (DBID=2896936214)

RMAN> set nocfau;

2> host ‘echo ts::XTTSTEST‘;

3> backup incremental from scn15718791765461

4> tag tts_incr_update tablespace ‘XTTSTEST‘ format

5> ‘/home/oracle/stage_source/%U‘;

6>

executing command: SET NOCFAU

using target database control file insteadof recovery catalog

ts::XTTSTEST

host command complete

Starting backup at 2017-11-13 15:14:33

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1443 instance=testdb1device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=1490 instance=testdb1device type=DISK

allocated channel: ORA_DISK_3

channel ORA_DISK_3: SID=2 instance=testdb1device type=DISK

allocated channel: ORA_DISK_4

channel ORA_DISK_4: SID=98 instance=testdb1device type=DISK

allocated channel: ORA_DISK_5

channel ORA_DISK_5: SID=148 instance=testdb1device type=DISK

allocated channel: ORA_DISK_6

channel ORA_DISK_6: SID=196 instance=testdb1device type=DISK

allocated channel: ORA_DISK_7

channel ORA_DISK_7: SID=244 instance=testdb1device type=DISK

allocated channel: ORA_DISK_8

channel ORA_DISK_8: SID=292 instance=testdb1device type=DISK

backup will be obsolete on date 2017-11-2015:14:36

archived logs will not be kept or backed up

channel ORA_DISK_1: starting compressedfull datafile backup set

channel ORA_DISK_1: specifying datafile(s)in backup set

input datafile file number=00041name=+ORADATA/testdb/datafile/xttstest.362.959887907

channel ORA_DISK_1: starting piece 1 at2017-11-13 15:14:36

channel ORA_DISK_1: finished piece 1 at2017-11-13 15:14:43

piece handle=/home/oracle/stage_source/k8sjfjqs_1_1tag=TTS_INCR_UPDATE comment=NONE

channel ORA_DISK_1: backup set complete,elapsed time: 00:00:07

using channel ORA_DISK_1

using channel ORA_DISK_2

using channel ORA_DISK_3

using channel ORA_DISK_4

using channel ORA_DISK_5

using channel ORA_DISK_6

using channel ORA_DISK_7

using channel ORA_DISK_8

backup will be obsolete on date 2017-11-2015:14:43

archived logs will not be kept or backed up

channel ORA_DISK_1: starting compressedfull datafile backup set

channel ORA_DISK_1: specifying datafile(s)in backup set

including current control file in backupset

channel ORA_DISK_1: starting piece 1 at2017-11-13 15:14:44

channel ORA_DISK_1: finished piece 1 at2017-11-13 15:14:45

piece handle=/home/oracle/stage_source/k9sjfjr3_1_1tag=TTS_INCR_UPDATE comment=NONE

channel ORA_DISK_1: backup set complete,elapsed time: 00:00:01

Finished backup at 2017-11-13 15:14:45

Recovery Manager complete.

--------------------------------------------------------------------

Done backing up incrementals

--------------------------------------------------------------------

db1:/home/oracle/tts$

本步驟在當前目錄(TMPDIR)創建如下文件:

1. tsbkupmap.txt - containing thetablespace names, datafile numbers and the incremental backup pieces:

db1:/home/oracle/tts$cat tsbkupmap.txt

XTTSTEST::41:::1=k8sjfjqs_1_1

2. incrbackups.txt - containing the actuallocation of the incremental backup pieces:

db1:/home/oracle/tts$cat incrbackups.txt

/home/oracle/stage_source/k8sjfjqs_1_1

3. rmanincrNaNd - containing the RMANscripts used to create the incremental backups.

4. xttdetnewfromscnsrc.sql - the PL/SQLscript used to create the files in this step

5. xttplan.txt.new- after the first run of‘xttdriver.pl -i‘ this is just a copy of the xttplan.txt

3.2. 傳輸增量備份至目標端

傳輸增量備份至目標端的stageondest目錄

db1:/home/oracle/tts$scp `cat incrbackups.txt` x.x.x.81:/home/oracle/stage_dest

[email protected]‘s password:

k8sjfjqs_1_1 100% 88KB 88.0KB/s 00:00

db1:/home/oracle/tts$

3.3. 在目標端應用增量備份

在目標端以oracle用戶登錄,並設置環境變量。從源端拷貝xttplan.txt 和 tsbkupmap.txt文件。

[oracle@testdb1 ~]$ cd $TMPDIR

[oracle@testdb1 tts]$ scp x.x.x.3:/home/oracle/tts/xttplan.txt .

[email protected]‘s password:

xttplan.txt 100% 30 0.0KB/s 00:00

[oracle@testdb1 tts]$ scp x.x.x.3:/home/oracle/tts/tsbkupmap.txt .

[email protected]‘s password:

tsbkupmap.txt 100% 30 0.0KB/s 00:00

運行 ‘xttdriver.pl -r‘,把增量備份與第二階段傳輸過來的數據文件進行合並

[oracle@testdb1 tts]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r

--------------------------------------------------------------------

Parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Start rollforward

--------------------------------------------------------------------

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Error:

------

/tmp/xxttconv_k3sjf6tk_1_1_41.sql executionfailed

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

直接運行sql腳本:

[oracle@testdb1 staging]$ sqlplus -L -s"/ as sysdba" @/tmp/xxttconv_k3sjf6tk_1_1_41.sql/home/oracle/tts/staging/k3sjf6tk_1_1 /home/oracle/tts/backupondest 6

ERROR IN CONVERSION ORA-19994: Message19994 not found; product=RDBMS;

facility=ORA

ORA-19600: input file is backup piece

(/home/oracle/tts/staging/k3sjf6tk_1_1)

ORA-19601: output file is backup piece

(/home/oracle/tts/backupondest/xib_k3sjf6tk_1_1_41)

CONVERTED BACKUPPIECE/home/oracle/tts/backupondest/xib_k3sjf6tk_1_1_41

PL/SQL procedure successfully completed.

還是出錯,參考如下文件,源端數據庫rmant備份不能啟動compress。

ORA-19837: INVALID BLOCKSIZE 0 IN BACKUPPIECE HEADER USING RMAN TTS BACKUPS DOING RECOVER (文檔ID 1486655.1)

[oracle@testdb1 tts]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r

============================================================

trace file is/home/oracle/tts/rollforward_Nov13_Mon_17_14_36_931//Nov13_Mon_17_14_36_931_.log

=============================================================

--------------------------------------------------------------------

Parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Start rollforward

--------------------------------------------------------------------

Can‘t locate DBI.pm in @INC (@INC contains: /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/5.10.0 /testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0 /testdb/orgrid/oracle/product/112/lib/testdb/orgrid/oracle/product/112/lib/asmcmd /testdb/orgrid/oracle/product/112/rdbms/lib/asmcmd/testdb/ordb/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi /testdb/ordb/oracle/product/112/perl/lib/5.10.0/testdb/ordb/oracle/product/112/perl/lib /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/5.10.0 /testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0 /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0 /testdb/orgrid/oracle/product/112/perl/lib/site_perl.) at /testdb/orgrid/oracle/product/112/lib/asmcmdshare.pm line 205.

BEGIN failed--compilation aborted at /testdb/orgrid/oracle/product/112/lib/asmcmdshare.pmline 205.

Compilation failed in require at /testdb/orgrid/oracle/product/112/bin/asmcmdcoreline 147.

BEGIN failed--compilation aborted at /testdb/orgrid/oracle/product/112/bin/asmcmdcoreline 147.

--------------------------------------------------------------------

End of rollforward phase

--------------------------------------------------------------------

Can‘t locate DBI.pm in @INC錯誤是可以忽略的,這是由於Perl pragmaasmcmdcore中使用“嚴格模式的結果。

本步驟增量備份會被放在備份目標目錄並和數據文件副本進行合並,本操作會重啟數據庫,在RAC環境中只啟動目標端一個數據庫實例。

可以在備份目標目錄查看備份數據:

grep ^backupondest xtt.properties

backupondest=+fra_sb

ASMCMD> ls

nnndn0_0.256.959966091

nnndn0_0.257.959966945

ASMCMD> pwd

+fra_sb/dest/backupset/2017_11_13

3.4. 確定下次增量備份的起始SCN

源端以oracle用戶登錄,並設置環境變量,執行‘xttdriver.pl -s‘

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

Prepare newscn for Tablespaces: ‘XTTSTEST‘

New /home/oracle/tts/xttplan.txt with FROMSCN‘s generated

本步驟原來的xttplan.txt會被備份為xttplan.txt<timestamp>,起始SCN會被記錄在xttplan.txt,如有需要執行‘xttdriver.pl -i‘進行下一次增量備份。

第三階段可以多次執行,每次執行需要運行‘xttdriver.pl -i‘,拷貝增量備份文件、xttplan.txt和tsbkupmap.txt到目標端,在目標端運行‘xttdriver.pl -r‘,最後在源端運行‘xttdriver.pl -s‘。

本次操作不重復執行階段3,直接執行階段4.

4. 完成表空間傳輸階段

本階段源端數據文件為只讀模式,目標端數據文件通地創建合並最終增量備份與源端數據文件保持一致。最後傳輸表空間元數據並導入到目標端數據庫。源端數據庫表空間置為只讀模式直到本階段完成。

4.1、設置表空間為READ ONLY

在源端以oracle用戶登錄,並設置環境變量,把XTTSTEST表空間設置為READ ONLY模式。

SYS@testdb1 > alter tablespace xttstest read only;

Tablespace altered.

4.2. 最後增量備份

源端:

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

$scp `cat incrbackups.txt` x.x.x.81:/home/oracle/stage_dest

目標端:

[oracle@testdb1 tts]$ scp x.x.x.3:/home/oracle/tts/xttplan.txt.

[email protected]‘s password:

xttplan.txt 100% 32 0.0KB/s 00:00

[oracle@testdb1 tts]$ scp x.x.x.3:/home/oracle/tts/tsbkupmap.txt .

[email protected]‘s password:

tsbkupmap.txt 100% 30 0.0KB/s 00:00

[oracle@testdb1 tts]$

4.3. 最後增量備份合並

[oracle@testdb1 tts]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r

============================================================

trace file is /home/oracle/tts/rollforward_Nov13_Mon_17_28_50_404//Nov13_Mon_17_28_50_404_.log

===========================================================

--------------------------------------------------------------------

Parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Start rollforward

--------------------------------------------------------------------

Can‘t locate DBI.pm in @INC (@INC contains:/testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0 /testdb/orgrid/oracle/product/112/lib/testdb/orgrid/oracle/product/112/lib/asmcmd /testdb/orgrid/oracle/product/112/rdbms/lib/asmcmd/testdb/ordb/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi /testdb/ordb/oracle/product/112/perl/lib/5.10.0/testdb/ordb/oracle/product/112/perl/lib /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/5.10.0 /testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0 /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/5.10.0/x86_64-linux-thread-multi /testdb/orgrid/oracle/product/112/perl/lib/5.10.0/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi/testdb/orgrid/oracle/product/112/perl/lib/site_perl/5.10.0 /testdb/orgrid/oracle/product/112/perl/lib/site_perl.) at /testdb/orgrid/oracle/product/112/lib/asmcmdshare.pm line 205.

BEGIN failed--compilation aborted at /testdb/orgrid/oracle/product/112/lib/asmcmdshare.pmline 205.

Compilation failed in require at /testdb/orgrid/oracle/product/112/bin/asmcmdcoreline 147.

BEGIN failed--compilation aborted at /testdb/orgrid/oracle/product/112/bin/asmcmdcoreline 147.

--------------------------------------------------------------------

End of rollforward phase

--------------------------------------------------------------------

[oracle@testdb1 tts]$

4.4.導入傳輸表空間元數據

[oracle@testdb1 tts]$$ORACLE_HOME/perl/bin/perl xttdriver.pl -e

===========================================================

trace file is/home/oracle/tts/generate_Nov13_Mon_17_29_45_222//Nov13_Mon_17_29_45_222_.log

===========================================================

--------------------------------------------------------------------

Parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done parsing properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Done checking properties

--------------------------------------------------------------------

--------------------------------------------------------------------

Generating plugin

--------------------------------------------------------------------

--------------------------------------------------------------------

Done generating plugin file/home/oracle/tts/xttplugin.txt

--------------------------------------------------------------------

[oracle@testdb1 tts]$ more /home/oracle/tts/xttplugin.txt

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

network_link=<ttslink>transport_full_check=no \

transport_tablespaces=XTTSTEST \

transport_datafiles=‘+DATA_SB/dest/datafile/xttstest_362_959887907‘

impdp "‘/ as sysdba‘" directory=dump_dirlogfile=tts_imp.log network_link=ttslink transport_full_check=notransport_tablespaces=XTTSTESTtransport_datafiles=‘+DATA_SB/dest/datafile/xttstest_362_959887907‘

SQL> create user xttstest identified by xttstest;

User created.

SQL> grant connect,resource to xttstest;

Grant succeeded.

SQL> exit

Disconnected from Oracle Database 11gEnterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real ApplicationClusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testingoptions

[oracle@testdb1 tts]$ impdp "‘/ as sysdba‘"directory=dump_dir logfile=tts_imp.log network_link=ttslinktransport_full_check=no transport_tablespaces=XTTSTESTtransport_datafiles=‘+DATA_SB/dest/datafile/xttstest_362_959887907‘

Import: Release 11.2.0.4.0 - Production onMon Nov 13 17:32:25 2017

Copyright (c) 1982, 2011, Oracle and/or itsaffiliates. All rights reserved.

Connected to: Oracle Database 11gEnterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real ApplicationClusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testingoptions

Starting"SYS"."SYS_IMPORT_TRANSPORTABLE_01": "/******** AS SYSDBA"directory=dump_dir logfile=tts_imp.log network_link=ttslinktransport_full_check=no transport_tablespaces=XTTSTESTtransport_datafiles=+DATA_SB/dest/datafile/xttstest_362_959887907

Source time zone is +08:00 and target timezone is +00:00.

Processing object typeTRANSPORTABLE_EXPORT/PLUGTS_BLK

Processing object typeTRANSPORTABLE_EXPORT/TABLE

Processing object typeTRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

Job"SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully completedat Mon Nov 13 17:32:51 2017 elapsed 0 00:00:25

4.5. 目標端表空間校驗

[oracle@testdb1tts]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production onMon Nov 13 17:34:22 2017

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

Connected to:

Oracle Database 11g Enterprise EditionRelease 11.2.0.4.0 - 64bit Production

With the Partitioning, Real ApplicationClusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testingoptions

SQL> alter tablespace xttstest readwrite;

Tablespace altered.

SQL> conn xttstest/xttstest

Connected.

SQL> select table_name from user_tables;

TABLE_NAME

------------------------------

TEST

XTTS_OBJECTS

XTTS_INDEX

XTTS_TABLES

XTTS_JOB

SQL> select count(1) from test;

COUNT(1)

----------

4

SQL>

參考:

https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=176801744221976&id=1902618.1&_afrWindowMode=0&_adf.ctrl-state=b39z5avbw_124


本文出自 “技術門徒” 博客,請務必保留此出處http://lizhhui.blog.51cto.com/3222144/1982243

利用DBMS_FILE_TRANSFER遷移數據庫從AIX至Linux