【TTS】傳輸表空間Linux ->AIX 基於rman

lhrbest發表於2016-02-12

TTS】傳輸表空間Linux asm -> AIX asm 基於rman

一.1  BLOG文件結構圖

wpsF6D5.tmp 

 

 

一.2  前言部分

 

一.2.1  導讀和注意事項

各位技術愛好者,看完本文後,你可以掌握如下的技能,也可以學到一些其它你所不知道的知識,~O(∩_∩)O~:

異構平臺下傳輸表空間的實施

傳輸表空間基於表空間的read only和rman2種方式

平臺位元組序、自包含概念

expdp/impdp的應用

 

  Tips:

       ① 若文章程式碼格式有錯亂,推薦使用搜狗360瀏覽器,也可以下載pdf格式的文件來檢視,pdf文件下載地址:http://yunpan.cn/cdEQedhCs2kFz (提取碼:ed9b 

       ② 本篇BLOG中命令的輸出部分需要特別關注的地方我都用灰色背景和粉紅色字型來表示,比如下邊的例子中,thread 1的最大歸檔日誌號為33thread 2的最大歸檔日誌號為43是需要特別關注的地方;而命令一般使用黃色背景和紅色字型注;對程式碼或程式碼輸出部分的注釋一般採用藍色字型表示

 

  List of Archived Logs in backup set 11

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

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

  1    32      1621589    2015-05-29 11:09:52 1625242    2015-05-29 11:15:48

  1    33      1625242    2015-05-29 11:15:48 1625293    2015-05-29 11:15:58

  2    42      1613951    2015-05-29 10:41:18 1625245    2015-05-29 11:15:49

  2    43      1625245    2015-05-29 11:15:49 1625253    2015-05-29 11:15:53

 

 

 

 

[ZFXDESKDB1:root]:/>lsvg -o

T_XDESK_APP1_vg

rootvg

[ZFXDESKDB1:root]:/>

00:27:22 SQL> alter tablespace idxtbs read write;

 

 

====》2097152*512/1024/1024/1024=1G 

 

 

 

 

 

 

 

本文如有錯誤或不完善的地方請大家多多指正,ITPUB留言或QQ皆可,您的批評指正是我寫作的最大動力。

 

 

一.2.2  相關參考文章連結

其他異構平臺遷移的一些文章參考:

【推薦】 oracle 異構平臺遷移之傳輸表空間一例 http://blog.itpub.net/26736162/viewspace-1391913/

【推薦】 oracle 傳輸表空間一例 http://blog.itpub.net/26736162/viewspace-1375260/

【推薦】 利用rman來實現linux平臺資料庫複製到windows平臺資料庫 http://blog.itpub.net/26736162/viewspace-1352436/

【推薦】 直接複製資料檔案實現linux平臺資料庫複製到windows平臺資料庫 http://blog.itpub.net/26736162/viewspace-1352243/

TTS】傳輸表空間Linux asm -> AIX asm  http://blog.itpub.net/26736162/viewspace-1987949/

 

 

一.3  相關知識點掃盲

可傳輸表空間的特性主要用於進行庫對庫的表空間複製,要進行傳輸的表空間必須置於read-only模式。如果生產庫不允許表空間置為只讀模式,沒關係,方法還是有的,通過RMAN備份也可以建立可傳輸表空間集。要使用可傳輸表空間的特性,oracle至少是8i企業版或更高版本。如果是相同作業系統平臺相互匯入,則8i及以上版本均可支援,但如果是不同作業系統平臺,資料庫版本至少10g。被傳輸的表空間即可以是字典管理,也可以是本地管理。並且自oracle9i開始,被傳輸表空間的block size可以與目標資料庫的block size不同。

 

可傳輸表空間(還有個集)最大的優勢是其速度比export/import或unload/load要快的多。因為可傳輸表空間主要是複製資料檔案到目標路徑,然後再使用export/import或Data Pump export/import等應用僅匯出/匯入表空間物件的後設資料到新資料庫。

關於可傳輸表空間,還有個集(Transportable Tablespace Sets)的建立,其中都提到了很重要一點,就是被傳輸的表空間在傳輸過程中必須置為 read-only。而在實際操作過程中,對於某些生產資料庫,將表空間置為 read-only 是件非常複雜的事情甚至完全不允許,有了 RMAN Transportable Tablespace,這一切都得以避免。RMAN 通過備份建立可傳輸表空間集,它並不需要存取活動的資料檔案,相應也就不需要將表空間置為 read-only。因此,資料庫可用性得到提升,尤其對於超大的表空間,因為被傳輸的表空間在此期間仍可進行讀寫操作,而且把表空間置為 read-only 模式可能會花費較長時間,

使用 RMAN 建立可傳輸表空間集,允許你在傳輸過程中指定目標恢復時間點或 SCN,這樣傳輸的資料可以更靈活,不必完全複製現有表空間,只要備份中存在,你就可以選擇性的恢復資料。例如,你的備份策略為保留一週,你希望建立的可傳輸表空間中資料是截止本月底最後一天的資料,那麼你在下個月第一週內任何時候都可以進行傳輸操作而不需要考慮這期間生產庫是否會有寫入操作。

 

 

一.3.1  注意事項

 

 

 

?  注意:

 

 source和target database的資料庫版本最好一致,否則會因為db time zone 不一致導致報如下錯誤,但是如果source大於等於target的話是可以的,向下相容的

ORA-39002: invalid operation

ORA-39322: Cannot use transportabletablespace with timestamp with timezone columns and different timezone version.

 

source和target端的字符集必須一致,例如如下情況報錯:

source為 ZHS16GBK,target為AL32UTF8

ORA-39123: Data Pump transportable tablespace job aborted

ORA-29345: cannot plug a tablespace into a database using an incompatible character set

 

Tartget db char set AL32UTF8 is not a superset of ZHS16GBK.

Failed to plug in a tablespace due to incompatible

  database character set"AL32UTF8" and

  transportable set database character set "ZHS16GBK"

 

  source和target database的compatible 引數最好一致,但source如果小於等於target端的話是可以的,例如source為11.2.0.4.0,target為11.2.0.0.0就不行,impdp的時候報錯:

ORA-39123: Data Pump transportable tablespace job aborted

ORA-00721: changes by release 11.2.0.4.0 cannot be used by release 11.2.0.0.0

 

 

 

 

一.4  實驗部分

 

一.4.1  實驗環境介紹

專案

source db

target db

db 型別

單例項

單例項

db version

11.2.0.3

11.2.0.4

db 儲存

ASM

ASM

ORACLE_SID

orclasm

ora2lhr

db_name

orclasm

ora2lhr

主機IP地址:

192.168.59.30

22.188.194.66

OS版本及kernel版本

RHEL6.5 64位,2.6.32-504.16.2.el6.x86_64

AIX 647.1.0.0

OS hostname

rhel6_lhr

ZFXDESKDB2

platform_name

Linux x86 64-bit

AIX-Based Systems (64-bit)

db time zone

14

14

compatible

11.2.0.0.0

11.2.0.4.0

字符集

ZHS16GBK

ZHS16GBK

歸檔模式

Archive Mode

Archive Mode

 

一.4.2  實驗目標

 

要實現將自定義的應用程式表空間app1tbs,app2tbs,idxtbs從源平臺傳遞到目標平臺,而在實際的工作過程中,需要將AIX上的資料庫遷移到Linux,或者將Linux上的資料庫遷移到AIX上,除了exp/impexpdp/impdp外,最常用的就是傳輸表空間了,若是整個庫遷移的話,我們需要做的就是把業務使用者和業務表空間的資料遷移過來就行,Undotempsystem等等的就不用遷移了,整個處理過程和本文件的處理過程大同小異,需要關注的是業務物件的個數、大小、狀態等。

wpsF6E5.tmp 

一.4.3  實驗過程

 

 

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

 

 

 

 

 

 

 

一.5  source端環境準備

wpsF6E6.tmp 

 

一.5.1  在源庫上建立3個使用者應用的表空間

 

[oracle@rhel6_lhr ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on 星期日 1月 31 23:34:27 2016

 

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

 

 

連線到:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 

23:34:27 SQL>  create tablespace app1tbs datafile '+DATA' size 10m;

 

表空間已建立。

 

已用時間:  00: 00: 07.60

23:34:42 SQL> create tablespace app2tbs datafile '+DATA' size 10m;

 

表空間已建立。

 

已用時間:  00: 00: 27.25

23:35:53 SQL> create tablespace idxtbs datafile '+DATA' size 10m;

 

表空間已建立。

 

已用時間:  00: 00: 09.45

23:36:09 SQL> set line 9999 pagesize 9999

23:36:12 SQL> SELECT   a.NAME,  b.NAME FROM v$tablespace a , v$datafile b WHERE a.TS#=b.TS#  ;

 

NAME                           NAME

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

SYSTEM                         +DATA/orclasm/datafile/system.256.850260145

SYSAUX                         +DATA/orclasm/datafile/sysaux.257.850260145

UNDOTBS1                       +DATA/orclasm/datafile/undotbs1.258.851526539

USERS                          +DATA/orclasm/datafile/users.259.850260147

EXAMPLE                        +DATA/orclasm/datafile/example.265.850260295

APP1TBS                        +DATA/orclasm/datafile/app1tbs.268.902619275

APP2TBS                        +DATA/orclasm/datafile/app2tbs.280.902619327

TS_LHR                         +DATA/orclasm/datafile/ts_lhr.269.852632495

ENCRYPTED_TS                   +DATA/orclasm/datafile/encrypted_ts.272.854650889

GOLDENGATE                     +DATA/orclasm/datafile/goldengate.273.862829891

IDXTBS                         +DATA/orclasm/datafile/idxtbs.281.902619361

TS_LHR                         +DATA/orclasm/datafile/ts_lhr.284.869738273

USERS                          +FRA/orclasm/datafile/users.449.880121199

SYSTEM                         +FRA/orclasm/datafile/system.349.880121287

 

已選擇14行。

 

已用時間:  00: 00: 00.80

23:36:21 SQL>

 

 

一.5.2  在相應的表空間建立表和索引

23:36:21 SQL> create user user_app1 identified by user_app1 default tablespace app1tbs;

 

使用者已建立。

 

已用時間:  00: 00: 00.14

23:40:13 SQL> create user user_app2 identified by user_app2 default tablespace app1tbs;

 

使用者已建立。

 

已用時間:  00: 00: 00.35

23:43:51 SQL> create user user_app2 identified by user_app2 default tablespace app2tbs;

 

使用者已建立。

 

已用時間:  00: 00: 02.72

23:43:56 SQL>  grant connect,resource to user_app1;

 

授權成功。

 

已用時間:  00: 00: 00.06

23:44:50 SQL> grant connect,resource to user_app2;

 

授權成功。

 

已用時間:  00: 00: 00.00

23:44:52 SQL> create table user_app1.app1_tab tablespace app1tbs as select * from scott.emp;

 

表已建立。

 

已用時間:  00: 00: 01.02

23:45:09 SQL>  create table user_app2.app2_tab tablespace app2tbs as select * from scott.dept;

 

表已建立。

 

已用時間:  00: 00: 00.23

23:45:27 SQL> create index user_app1.idx_emp_ename on user_app1.app1_tab(ename) tablespace idxtbs;

 

索引已建立。

 

已用時間:  00: 00: 00.25

23:45:51 SQL> create index user_app2.idx_dept_dname on user_app2.app2_tab(dname) tablespace idxtbs;

 

索引已建立。

 

已用時間:  00: 00: 00.01

23:46:13 SQL>

 

一.6  判斷平臺支援並確定位元組序

如果傳輸表空間集到不同的平臺,則要確定對於源和目標平臺這種跨平臺表空間被支援,也要確定每個平臺的位元組序,如果平臺具有相同的位元組序,則不需要進行轉化,否則必須做一個表空間集轉化,在源端或目標端。

一.6.1  在源平臺查詢

23:46:13 SQL> col platform_name for a40

23:48:55 SQL> select d.platform_name,tp.endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name;

 

PLATFORM_NAME                            ENDIAN_FORMAT

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

Linux x86 64-bit                         Little

 

已用時間:  00: 00: 00.19

23:49:13 SQL>

 

結論:當前的系統平臺支援跨平臺表空間傳輸(因為上面的查詢有記錄返回)

 

一.6.2  在目標平臺查詢

 

[ZFXDESKDB2:oracle]:/oracle>ORACLE_SID=ora2lhr

[ZFXDESKDB2:oracle]:/oracle>sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Mon Feb 1 13:47:14 2016

 

Copyright (c) 1982, 2013, Oracle.  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

 

SYS@ora2lhr> col platform_name for a40

SYS@ora2lhr> select d.platform_name,tp.endian_format from v$transportable_platform tp,v$database d where tp.platform_name=d.platform_name;

 

PLATFORM_NAME                            ENDIAN_FORMAT

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

AIX-Based Systems (64-bit)               Big

 

 

結論: 當前的AIX平臺支援跨平臺的表空間傳輸

源平臺和目標平臺的Endian_format 不同,source端為Littletarget端為Big,所以需要進行表空間集轉換,前邊說過在源端或目標端都可以進行轉換,這裡我們選擇在目標端來進行轉換

 

一.7  選擇自包含的表空間集

一.7.1  進行檢查

Indicates whether a full or partial dependency check is required. If TRUE, treats all IN and OUT pointers(dependencies) and captures them as violations if they are not self-contained in the transportable set.

先試試要傳輸app1tbsidxtbs2個表空間

SQL> execute dbms_tts.transport_set_check('app1tbs,idxtbs',true);

 

PL/SQL procedure successfully completed.

 

 

一.7.2  檢視檢查結果

SQL> col violations for a70

 

23:50:53 SQL> select * from transport_set_violations;

 

VIOLATIONS

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

ORA-39907: 索引 USER_APP2.IDX_DEPT_DNAME (在表空間 IDXTBS 中) 指向表 USER_APP2.APP2_TAB (在表空間 APP2TBS 中)。

 

已用時間:  00: 00: 00.18

23:51:14 SQL>

 

結論: 在idxtbs表空間中IDX_DEPT_DNAME索引指向了表空間集外的SYS.APP2_TAB表,所以這裡選擇app1tabs,app2tabs,idxtbs作為新的表空間集再次進行檢查

 

23:51:14 SQL> execute dbms_tts.transport_set_check('app1tbs,app2tbs,idxtbs',true);

 

PL/SQL 過程已成功完成。

 

已用時間:  00: 00: 07.24

23:52:14 SQL> select * from transport_set_violations;

 

未選定行

 

已用時間:  00: 00: 00.00

23:52:54 SQL>

結論: 此時這個表空間集已經不在違背自包含的條件,可以確定為一個可傳輸表空間集

 

一.8  產生可傳輸表空間集

一.8.1  rman全備份

對源資料庫執行備份,在執行備份時一定要加上include current controlfile否則執行transport tablespace命令時會出現以下錯誤資訊:

Automatic instance removed

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of tranport tablespace command at 03/26/2015 20:24:22

RMAN-03015: error occurred in stored script Memory Script

RMAN-06026: some targets not found - aborting restore

RMAN-06024: no backup or copy of the control file found to restore

 

 

[oracle@rhel6_lhr orclasm]$ rman target /

 

恢復管理器: Release 11.2.0.3.0 - Production on 星期一 2月 1 22:05:43 2016

 

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

 

已連線到目標資料庫: ORCLASM (DBID=3424884828)

RMAN> list backup;

 

說明與資料檔案庫中的任何備份都不匹配

 

RMAN> backup as backupset database  format  '/u05/oracle/oracle_bk/orclasm/full_%n_%T_%t_%s_%p.bak' include current controlfile plus archivelog delete input;

 

 

啟動 backup 於 2016-02-01 22:11:24

當前日誌已存檔

使用通道 ORA_DISK_1

使用通道 ORA_DISK_2

通道 ORA_DISK_1: 正在啟動歸檔日誌備份集

通道 ORA_DISK_1: 正在指定備份集內的歸檔日誌

輸入歸檔日誌執行緒=1 序列=2400 RECID=2409 STAMP=898694914

輸入歸檔日誌執行緒=1 序列=2401 RECID=2410 STAMP=898702456

輸入歸檔日誌執行緒=1 序列=2402 RECID=2411 STAMP=898703657

輸入歸檔日誌執行緒=1 序列=2403 RECID=2412 STAMP=898703964

輸入歸檔日誌執行緒=1 序列=2404 RECID=2413 STAMP=898705171

輸入歸檔日誌執行緒=1 序列=2405 RECID=2414 STAMP=898705314

輸入歸檔日誌執行緒=1 序列=2406 RECID=2415 STAMP=898707838

通道 ORA_DISK_1: 正在啟動段 1 於 2016-02-01 22:12:08

通道 ORA_DISK_2: 正在啟動歸檔日誌備份集

通道 ORA_DISK_2: 正在指定備份集內的歸檔日誌

輸入歸檔日誌執行緒=1 序列=2407 RECID=2416 STAMP=898708044

輸入歸檔日誌執行緒=1 序列=2408 RECID=2417 STAMP=902613950

輸入歸檔日誌執行緒=1 序列=2409 RECID=2418 STAMP=902614593

輸入歸檔日誌執行緒=1 序列=2410 RECID=2419 STAMP=902618226

輸入歸檔日誌執行緒=1 序列=2411 RECID=2420 STAMP=902699234

輸入歸檔日誌執行緒=1 序列=2412 RECID=2421 STAMP=902700168

輸入歸檔日誌執行緒=1 序列=2413 RECID=2422 STAMP=902700702

通道 ORA_DISK_2: 正在啟動段 1 於 2016-02-01 22:12:38

通道 ORA_DISK_1: 已完成段 1 於 2016-02-01 22:12:47

段控制程式碼=/home/oracle/oracle_bk/orclasm/q9qss7lj_1_1_ORCLASM.bak 標記=TAG20160201T221152 註釋=NONE

通道 ORA_DISK_1: 備份集已完成, 經過時間:00:00:39

通道 ORA_DISK_2: 已完成段 1 於 2016-02-01 22:13:17

段控制程式碼=/home/oracle/oracle_bk/orclasm/qaqss7lp_1_1_ORCLASM.bak 標記=TAG20160201T221152 註釋=NONE

通道 ORA_DISK_2: 備份集已完成, 經過時間:00:00:39

完成 backup 於 2016-02-01 22:13:17

 

啟動 backup 於 2016-02-01 22:13:22

使用通道 ORA_DISK_1

使用通道 ORA_DISK_2

通道 ORA_DISK_1: 正在啟動全部資料檔案備份集

通道 ORA_DISK_1: 正在指定備份集內的資料檔案

輸入資料檔案: 檔案號=00033 名稱=+FRA/orclasm/datafile/users.449.880121199

輸入資料檔案: 檔案號=00002 名稱=+DATA/orclasm/datafile/sysaux.257.850260145

輸入資料檔案: 檔案號=00001 名稱=+DATA/orclasm/datafile/system.256.850260145

輸入資料檔案: 檔案號=00005 名稱=+DATA/orclasm/datafile/example.265.850260295

輸入資料檔案: 檔案號=00008 名稱=+DATA/orclasm/datafile/ts_lhr.269.852632495

輸入資料檔案: 檔案號=00014 名稱=+DATA/orclasm/datafile/ts_lhr.284.869738273

輸入資料檔案: 檔案號=00034 名稱=+FRA/orclasm/datafile/system.349.880121287

通道 ORA_DISK_1: 正在啟動段 1 於 2016-02-01 22:13:40

通道 ORA_DISK_2: 正在啟動全部資料檔案備份集

通道 ORA_DISK_2: 正在指定備份集內的資料檔案

輸入資料檔案: 檔案號=00004 名稱=+DATA/orclasm/datafile/users.259.850260147

輸入資料檔案: 檔案號=00003 名稱=+DATA/orclasm/datafile/undotbs1.258.851526539

輸入資料檔案: 檔案號=00010 名稱=+DATA/orclasm/datafile/goldengate.273.862829891

輸入資料檔案: 檔案號=00006 名稱=+DATA/orclasm/datafile/app1tbs.268.902619275

輸入資料檔案: 檔案號=00007 名稱=+DATA/orclasm/datafile/app2tbs.280.902619327

輸入資料檔案: 檔案號=00011 名稱=+DATA/orclasm/datafile/idxtbs.281.902619361

輸入資料檔案: 檔案號=00009 名稱=+DATA/orclasm/datafile/encrypted_ts.272.854650889

通道 ORA_DISK_2: 正在啟動段 1 於 2016-02-01 22:13:47

通道 ORA_DISK_1: 已完成段 1 於 2016-02-01 22:21:15

段控制程式碼=/u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700816_1867_1.bak 標記=TAG20160201T221331 註釋=NONE

通道 ORA_DISK_1: 備份集已完成, 經過時間:00:07:35

通道 ORA_DISK_1: 正在啟動全部資料檔案備份集

通道 ORA_DISK_1: 正在指定備份集內的資料檔案

備份集內包括當前控制檔案

通道 ORA_DISK_1: 正在啟動段 1 於 2016-02-01 22:21:52

通道 ORA_DISK_1: 已完成段 1 於 2016-02-01 22:22:17

段控制程式碼=/u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902701286_1869_1.bak 標記=TAG20160201T221331 註釋=NONE

通道 ORA_DISK_1: 備份集已完成, 經過時間:00:00:25

通道 ORA_DISK_2: 已完成段 1 於 2016-02-01 22:26:07

段控制程式碼=/u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700821_1868_1.bak 標記=TAG20160201T221331 註釋=NONE

通道 ORA_DISK_2: 備份集已完成, 經過時間:00:12:20

完成 backup 於 2016-02-01 22:26:07

 

啟動 backup 於 2016-02-01 22:26:11

當前日誌已存檔

使用通道 ORA_DISK_1

使用通道 ORA_DISK_2

通道 ORA_DISK_1: 正在啟動歸檔日誌備份集

通道 ORA_DISK_1: 正在指定備份集內的歸檔日誌

輸入歸檔日誌執行緒=1 序列=2414 RECID=2423 STAMP=902701474

通道 ORA_DISK_1: 正在啟動段 1 於 2016-02-01 22:26:41

通道 ORA_DISK_2: 正在啟動歸檔日誌備份集

通道 ORA_DISK_2: 正在指定備份集內的歸檔日誌

輸入歸檔日誌執行緒=1 序列=2415 RECID=2424 STAMP=902701578

通道 ORA_DISK_2: 正在啟動段 1 於 2016-02-01 22:26:46

通道 ORA_DISK_1: 已完成段 1 於 2016-02-01 22:26:53

段控制程式碼=/home/oracle/oracle_bk/orclasm/qeqss8h1_1_1_ORCLASM.bak 標記=TAG20160201T222636 註釋=NONE

通道 ORA_DISK_1: 備份集已完成, 經過時間:00:00:12

通道 ORA_DISK_2: 已完成段 1 於 2016-02-01 22:27:01

段控制程式碼=/home/oracle/oracle_bk/orclasm/qfqss8h5_1_1_ORCLASM.bak 標記=TAG20160201T222636 註釋=NONE

通道 ORA_DISK_2: 備份集已完成, 經過時間:00:00:15

完成 backup 於 2016-02-01 22:27:01

 

啟動 Control File and SPFILE Autobackup 於 2016-02-01 22:27:08

段 handle=/home/oracle/oracle_bk/orclasm/ctlfile_autoback_ORCLASM_c-3424884828-20160201-0a.bak comment=NONE

完成 Control File and SPFILE Autobackup 於 2016-02-01 22:27:33

 

RMAN> list backupset;

 

 

備份集列表

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

 

 

BS 關鍵字  大小       裝置型別佔用時間 完成時間          

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

1743    276.69M    DISK        00:00:35     2016-02-01 22:12:38

        BP 關鍵字: 1814   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T221152

段名:/home/oracle/oracle_bk/orclasm/q9qss7lj_1_1_ORCLASM.bak

 

  備份集 1743 中的已存檔日誌列表

  執行緒序列     低 SCN    時間下限            下一個 SCN   下一次

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

  1    2400    55314243   2015-12-17 11:42:30 55356997   2015-12-17 13:28:31

  1    2401    55356997   2015-12-17 13:28:31 55380655   2015-12-17 15:34:02

  1    2402    55380655   2015-12-17 15:34:02 55391244   2015-12-17 15:54:10

  1    2403    55391244   2015-12-17 15:54:10 55401844   2015-12-17 15:59:14

  1    2404    55401844   2015-12-17 15:59:14 55411350   2015-12-17 16:19:24

  1    2405    55411350   2015-12-17 16:19:24 55423877   2015-12-17 16:21:47

  1    2406    55423877   2015-12-17 16:21:47 55455247   2015-12-17 17:03:49

 

BS 關鍵字  大小       裝置型別佔用時間 完成時間          

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

1744    214.24M    DISK        00:01:01     2016-02-01 22:13:10

        BP 關鍵字: 1815   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T221152

段名:/home/oracle/oracle_bk/orclasm/qaqss7lp_1_1_ORCLASM.bak

 

  備份集 1744 中的已存檔日誌列表

  執行緒序列     低 SCN    時間下限            下一個 SCN   下一次

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

  1    2407    55455247   2015-12-17 17:03:49 55466900   2015-12-17 17:07:18

  1    2408    55466900   2015-12-17 17:07:18 55509831   2016-01-31 22:05:41

  1    2409    55509831   2016-01-31 22:05:41 55521588   2016-01-31 22:16:26

  1    2410    55521588   2016-01-31 22:16:26 55554213   2016-01-31 23:17:01

  1    2411    55554213   2016-01-31 23:17:01 55596287   2016-02-01 21:47:10

  1    2412    55596287   2016-02-01 21:47:10 55599466   2016-02-01 22:02:41

  1    2413    55599466   2016-02-01 22:02:41 55620029   2016-02-01 22:11:25

 

BS 關鍵字  型別 LV 大小       裝置型別 經過時間 完成時間          

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

1745    Full    2.34G      DISK        00:07:33     2016-02-01 22:21:09

        BP 關鍵字: 1816   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T221331

段名:/u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700816_1867_1.bak

  備份集 1745 中的資料檔案列表

  檔案 LV 型別 Ckp SCN    Ckp 時間            名稱

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

  1       Full 55620642   2016-02-01 22:13:41 +DATA/orclasm/datafile/system.256.850260145

  2       Full 55620642   2016-02-01 22:13:41 +DATA/orclasm/datafile/sysaux.257.850260145

  5       Full 55620642   2016-02-01 22:13:41 +DATA/orclasm/datafile/example.265.850260295

  8       Full 55620642   2016-02-01 22:13:41 +DATA/orclasm/datafile/ts_lhr.269.852632495

  14      Full 55620642   2016-02-01 22:13:41 +DATA/orclasm/datafile/ts_lhr.284.869738273

  33      Full 55620642   2016-02-01 22:13:41 +FRA/orclasm/datafile/users.449.880121199

  34      Full 55620642   2016-02-01 22:13:41 +FRA/orclasm/datafile/system.349.880121287

 

BS 關鍵字  型別 LV 大小       裝置型別 經過時間 完成時間          

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

1746    Full    12.77M     DISK        00:00:44     2016-02-01 22:22:10

        BP 關鍵字: 1817   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T221331

段名:/u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902701286_1869_1.bak

  包括的控制檔案: Ckp SCN: 55622293     Ckp 時間: 2016-02-01 22:21:30

 

BS 關鍵字  型別 LV 大小       裝置型別 經過時間 完成時間          

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

1747    Full    2.54G      DISK        00:12:22     2016-02-01 22:26:03

        BP 關鍵字: 1818   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T221331

段名:/u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700821_1868_1.bak

  備份集 1747 中的資料檔案列表

  檔案 LV 型別 Ckp SCN    Ckp 時間            名稱

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

  3       Full 55620651   2016-02-01 22:13:47 +DATA/orclasm/datafile/undotbs1.258.851526539

  4       Full 55620651   2016-02-01 22:13:47 +DATA/orclasm/datafile/users.259.850260147

  6       Full 55620651   2016-02-01 22:13:47 +DATA/orclasm/datafile/app1tbs.268.902619275

  7       Full 55620651   2016-02-01 22:13:47 +DATA/orclasm/datafile/app2tbs.280.902619327

  9       Full 55620651   2016-02-01 22:13:47 +DATA/orclasm/datafile/encrypted_ts.272.854650889

  10      Full 55620651   2016-02-01 22:13:47 +DATA/orclasm/datafile/goldengate.273.862829891

  11      Full 55620651   2016-02-01 22:13:47 +DATA/orclasm/datafile/idxtbs.281.902619361

 

BS 關鍵字  大小       裝置型別佔用時間 完成時間          

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

1748    39.85M     DISK        00:00:10     2016-02-01 22:26:51

        BP 關鍵字: 1819   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T222636

段名:/home/oracle/oracle_bk/orclasm/qeqss8h1_1_1_ORCLASM.bak

 

  備份集 1748 中的已存檔日誌列表

  執行緒序列     低 SCN    時間下限            下一個 SCN   下一次

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

  1    2414    55620029   2016-02-01 22:11:25 55623076   2016-02-01 22:24:03

 

BS 關鍵字  大小       裝置型別佔用時間 完成時間          

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

1749    16.97M     DISK        00:00:07     2016-02-01 22:26:52

        BP 關鍵字: 1820   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T222636

段名:/home/oracle/oracle_bk/orclasm/qfqss8h5_1_1_ORCLASM.bak

 

  備份集 1749 中的已存檔日誌列表

  執行緒序列     低 SCN    時間下限            下一個 SCN   下一次

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

  1    2415    55623076   2016-02-01 22:24:03 55623713   2016-02-01 22:26:13

 

BS 關鍵字  型別 LV 大小       裝置型別 經過時間 完成時間          

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

1750    Full    12.80M     DISK        00:00:20     2016-02-01 22:27:28

        BP 關鍵字: 1821   狀態: AVAILABLE  已壓縮: NO  標記: TAG20160201T222708

段名:/home/oracle/oracle_bk/orclasm/ctlfile_autoback_ORCLASM_c-3424884828-20160201-0a.bak

  包含的 SPFILE: 修改時間: 2015-11-11 19:53:11

  SPFILE db_unique_name: ORCLASM

  包括的控制檔案: Ckp SCN: 55624410     Ckp 時間: 2016-02-01 22:27:08

 

一.8.2  生成結果集

這個轉換步驟需要特別注意的是/u05/tmp的空間大小,因為需要建立一個輔助例項,所以空間大小至少應該是source庫表空間大小的總和加上需要傳輸的表空間的資料檔案的大小,否則會因為空間不足而導致轉換失敗。

RMAN> transport tablespace app1tbs,app2tbs,idxtbs tablespace destination '/u05/tmp' auxiliary destination '/u05/tmp';

 

使用目標資料庫控制檔案替代恢復目錄

RMAN-05026: 警告: 假定以下表空間集適用於指定的時間點

 

表空間列表要求具有 UNDO 段

表空間 SYSTEM

表空間 UNDOTBS1

 

使用 SID='ypkw' 建立自動例項

 

供自動例項使用的初始化引數:

db_name=ORCLASM

db_unique_name=ypkw_tspitr_ORCLASM

compatible=11.2.0.0.0

db_block_size=8192

db_files=200

sga_target=280M

processes=50

db_create_file_dest=/u05/tmp

log_archive_dest_1='location=/u05/tmp'

#No auxiliary parameter file used

 

 

啟動自動例項 ORCLASM

 

Oracle 例項已啟動

 

系統全域性區域總計     292278272 位元組

 

Fixed Size                     2227744 位元組

Variable Size                100663776 位元組

Database Buffers             184549376 位元組

Redo Buffers                   4837376 位元組

自動例項已建立

對恢復集表空間執行 TRANSPORT_SET_CHECK

TRANSPORT_SET_CHECK 已成功完成

 

記憶體指令碼的內容:

{

# set requested point in time

set until  scn 55627689;

# restore the controlfile

restore clone controlfile;

# mount the controlfile

sql clone 'alter database mount clone database';

# archive current online log

sql 'alter system archive log current';

}

正在執行記憶體指令碼

 

正在執行命令: SET until clause

 

啟動 restore 於 2016-02-01 22:44:21

分配的通道: ORA_AUX_DISK_1

通道 ORA_AUX_DISK_1: SID=59 裝置型別=DISK

分配的通道: ORA_AUX_DISK_2

通道 ORA_AUX_DISK_2: SID=10 裝置型別=DISK

 

通道 ORA_AUX_DISK_1: 正在開始還原資料檔案備份集

通道 ORA_AUX_DISK_1: 正在還原控制檔案

通道 ORA_AUX_DISK_1: 正在讀取備份片段 /home/oracle/oracle_bk/orclasm/ctlfile_autoback_ORCLASM_c-3424884828-20160201-0a.bak

通道 ORA_AUX_DISK_1: 段控制程式碼 = /home/oracle/oracle_bk/orclasm/ctlfile_autoback_ORCLASM_c-3424884828-20160201-0a.bak 標記 = TAG20160201T222708

通道 ORA_AUX_DISK_1: 已還原備份片段 1

通道 ORA_AUX_DISK_1: 還原完成, 用時: 00:00:01

輸出檔名=/u05/tmp/ORCLASM/controlfile/o1_mf_cbyvtc77_.ctl

完成 restore 於 2016-02-01 22:44:28

 

sql 語句: alter database mount clone database

 

sql 語句: alter system archive log current

 

記憶體指令碼的內容:

{

# set requested point in time

set until  scn 55627689;

# set destinations for recovery set and auxiliary set datafiles

set newname for clone datafile  1 to new;

set newname for clone datafile  34 to new;

set newname for clone datafile  3 to new;

set newname for clone datafile  2 to new;

set newname for clone tempfile  1 to new;

set newname for datafile  6 to

"/u05/tmp/o1_mf_app1tbs_%u_.dbf";

set newname for datafile  7 to

"/u05/tmp/o1_mf_app2tbs_%u_.dbf";

set newname for datafile  11 to

"/u05/tmp/o1_mf_idxtbs_%u_.dbf";

# switch all tempfiles

switch clone tempfile all;

# restore the tablespaces in the recovery set and the auxiliary set

restore clone datafile  1, 34, 3, 2, 6, 7, 11;

switch clone datafile all;

}

正在執行記憶體指令碼

 

正在執行命令: SET until clause

 

正在執行命令: SET NEWNAME

 

正在執行命令: SET NEWNAME

 

正在執行命令: SET NEWNAME

 

正在執行命令: SET NEWNAME

 

正在執行命令: SET NEWNAME

 

正在執行命令: SET NEWNAME

 

正在執行命令: SET NEWNAME

 

正在執行命令: SET NEWNAME

 

臨時檔案 1 在控制檔案中已重新命名為 /u05/tmp/ORCLASM/datafile/o1_mf_temp_%u_.tmp

 

啟動 restore 於 2016-02-01 22:44:42

使用通道 ORA_AUX_DISK_1

使用通道 ORA_AUX_DISK_2

 

通道 ORA_AUX_DISK_1: 正在開始還原資料檔案備份集

通道 ORA_AUX_DISK_1: 正在指定從備份集還原的資料檔案

通道 ORA_AUX_DISK_1: 將資料檔案 00001 還原到 /u05/tmp/ORCLASM/datafile/o1_mf_system_%u_.dbf

通道 ORA_AUX_DISK_1: 將資料檔案 00034 還原到 /u05/tmp/ORCLASM/datafile/o1_mf_system_%u_.dbf

通道 ORA_AUX_DISK_1: 將資料檔案 00002 還原到 /u05/tmp/ORCLASM/datafile/o1_mf_sysaux_%u_.dbf

通道 ORA_AUX_DISK_1: 正在讀取備份片段 /u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700816_1867_1.bak

通道 ORA_AUX_DISK_2: 正在開始還原資料檔案備份集

通道 ORA_AUX_DISK_2: 正在指定從備份集還原的資料檔案

通道 ORA_AUX_DISK_2: 將資料檔案 00003 還原到 /u05/tmp/ORCLASM/datafile/o1_mf_undotbs1_%u_.dbf

通道 ORA_AUX_DISK_2: 將資料檔案 00006 還原到 /u05/tmp/o1_mf_app1tbs_%u_.dbf

通道 ORA_AUX_DISK_2: 將資料檔案 00007 還原到 /u05/tmp/o1_mf_app2tbs_%u_.dbf

通道 ORA_AUX_DISK_2: 將資料檔案 00011 還原到 /u05/tmp/o1_mf_idxtbs_%u_.dbf

通道 ORA_AUX_DISK_2: 正在讀取備份片段 /u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700821_1868_1.bak

通道 ORA_AUX_DISK_2: 段控制程式碼 = /u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700821_1868_1.bak 標記 = TAG20160201T221331

通道 ORA_AUX_DISK_2: 已還原備份片段 1

通道 ORA_AUX_DISK_2: 還原完成, 用時: 00:00:25

通道 ORA_AUX_DISK_1: 段控制程式碼 = /u05/oracle/oracle_bk/orclasm/full_ORCLASMx_20160201_902700816_1867_1.bak 標記 = TAG20160201T221331

通道 ORA_AUX_DISK_1: 已還原備份片段 1

通道 ORA_AUX_DISK_1: 還原完成, 用時: 00:01:35

完成 restore 於 2016-02-01 22:46:21

 

資料檔案 1 已轉換成資料檔案副本

輸入資料檔案副本 RECID=58 STAMP=902702782 檔名=/u05/tmp/ORCLASM/datafile/o1_mf_system_cbyvtz00_.dbf

資料檔案 34 已轉換成資料檔案副本

輸入資料檔案副本 RECID=59 STAMP=902702782 檔名=/u05/tmp/ORCLASM/datafile/o1_mf_system_cbyvtz5j_.dbf

資料檔案 3 已轉換成資料檔案副本

輸入資料檔案副本 RECID=60 STAMP=902702782 檔名=/u05/tmp/ORCLASM/datafile/o1_mf_undotbs1_cbyvtyz4_.dbf

資料檔案 2 已轉換成資料檔案副本

輸入資料檔案副本 RECID=61 STAMP=902702782 檔名=/u05/tmp/ORCLASM/datafile/o1_mf_sysaux_cbyvtyxm_.dbf

資料檔案 6 已轉換成資料檔案副本

輸入資料檔案副本 RECID=62 STAMP=902702782 檔名=/u05/tmp/o1_mf_app1tbs_cbyvtz0l_.dbf

資料檔案 7 已轉換成資料檔案副本

輸入資料檔案副本 RECID=63 STAMP=902702782 檔名=/u05/tmp/o1_mf_app2tbs_cbyvtz1y_.dbf

資料檔案 11 已轉換成資料檔案副本

輸入資料檔案副本 RECID=64 STAMP=902702782 檔名=/u05/tmp/o1_mf_idxtbs_cbyvtz52_.dbf

 

記憶體指令碼的內容:

{

# set requested point in time

set until  scn 55627689;

# online the datafiles restored or switched

sql clone "alter database datafile  1 online";

sql clone "alter database datafile  34 online";

sql clone "alter database datafile  3 online";

sql clone "alter database datafile  2 online";

sql clone "alter database datafile  6 online";

sql clone "alter database datafile  7 online";

sql clone "alter database datafile  11 online";

# recover and open resetlogs

recover clone database tablespace  "APP1TBS", "APP2TBS", "IDXTBS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;

alter clone database open resetlogs;

}

正在執行記憶體指令碼

 

正在執行命令: SET until clause

 

sql 語句: alter database datafile  1 online

 

sql 語句: alter database datafile  34 online

 

sql 語句: alter database datafile  3 online

 

sql 語句: alter database datafile  2 online

 

sql 語句: alter database datafile  6 online

 

sql 語句: alter database datafile  7 online

 

sql 語句: alter database datafile  11 online

 

啟動 recover 於 2016-02-01 22:46:23

使用通道 ORA_AUX_DISK_1

使用通道 ORA_AUX_DISK_2

 

正在開始介質的恢復

 

執行緒 1 序列 2414 的歸檔日誌已作為檔案 +FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2414.283.902701451 存在於磁碟上

執行緒 1 序列 2415 的歸檔日誌已作為檔案 +FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2415.467.902701575 存在於磁碟上

執行緒 1 序列 2416 的歸檔日誌已作為檔案 +FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2416.332.902701653 存在於磁碟上

執行緒 1 序列 2417 的歸檔日誌已作為檔案 +FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2417.308.902701787 存在於磁碟上

執行緒 1 序列 2418 的歸檔日誌已作為檔案 +FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2418.366.902701939 存在於磁碟上

歸檔日誌檔名=+FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2414.283.902701451 執行緒=1 序列=2414

歸檔日誌檔名=+FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2415.467.902701575 執行緒=1 序列=2415

歸檔日誌檔名=+FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2416.332.902701653 執行緒=1 序列=2416

歸檔日誌檔名=+FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2417.308.902701787 執行緒=1 序列=2417

歸檔日誌檔名=+FRA/orclasm/archivelog/2016_02_01/thread_1_seq_2418.366.902701939 執行緒=1 序列=2418

介質恢復完成, 用時: 00:00:14

完成 recover 於 2016-02-01 22:46:41

 

資料庫已開啟

 

記憶體指令碼的內容:

{

# make read only the tablespace that will be exported

sql clone 'alter tablespace  APP1TBS read only';

sql clone 'alter tablespace  APP2TBS read only';

sql clone 'alter tablespace  IDXTBS read only';

# create directory for datapump export

sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as ''

/u05/tmp''";

}

正在執行記憶體指令碼

 

sql 語句: alter tablespace  APP1TBS read only

 

sql 語句: alter tablespace  APP2TBS read only

 

sql 語句: alter tablespace  IDXTBS read only

 

sql 語句: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u05/tmp''

 

正在執行後設資料匯出...

   EXPDP> 啟動 "SYS"."TSPITR_EXP_ypkw": 

   EXPDP> 處理物件型別 TRANSPORTABLE_EXPORT/PLUGTS_BLK

   EXPDP> 處理物件型別 TRANSPORTABLE_EXPORT/TABLE

   EXPDP> 處理物件型別 TRANSPORTABLE_EXPORT/INDEX/INDEX

   EXPDP> 處理物件型別 TRANSPORTABLE_EXPORT/INDEX_STATISTICS

   EXPDP> 處理物件型別 TRANSPORTABLE_EXPORT/TABLE_STATISTICS

   EXPDP> 處理物件型別 TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

   EXPDP> 已成功載入/解除安裝了主表 "SYS"."TSPITR_EXP_ypkw"

   EXPDP> ******************************************************************************

   EXPDP> SYS.TSPITR_EXP_ypkw 的轉儲檔案集為:

   EXPDP>   /u05/tmp/dmpfile.dmp

   EXPDP> ******************************************************************************

   EXPDP> 可傳輸表空間 APP1TBS 所需的資料檔案:

   EXPDP>   /u05/tmp/o1_mf_app1tbs_cbyvtz0l_.dbf

   EXPDP> 可傳輸表空間 APP2TBS 所需的資料檔案:

   EXPDP>   /u05/tmp/o1_mf_app2tbs_cbyvtz1y_.dbf

   EXPDP> 可傳輸表空間 IDXTBS 所需的資料檔案:

   EXPDP>   /u05/tmp/o1_mf_idxtbs_cbyvtz52_.dbf

   EXPDP> 作業 "SYS"."TSPITR_EXP_ypkw" 已於 22:48:00 成功完成

匯出完畢

 

/*

   The following command may be used to import the tablespaces.

   Substitute values for <logon> and <directory>.

   impdp <logon> directory=<directory> dumpfile= 'dmpfile.dmp' transport_datafiles= /u05/tmp/o1_mf_app1tbs_cbyvtz0l_.dbf, /u05/tmp/o1_mf_app2tbs_cbyvtz1y_.dbf, /u05/tmp/o1_mf_idxtbs_cbyvtz52_.dbf

*/

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

-- Start of sample PL/SQL script for importing the tablespaces

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

-- creating directory objects

CREATE DIRECTORY STREAMS$DIROBJ$1 AS  '/u05/tmp/';

CREATE DIRECTORY STREAMS$DIROBJ$DPDIR AS  '/u05/tmp';

/* PL/SQL Script to import the exported tablespaces */

DECLARE

  -- the datafiles

  tbs_files     dbms_streams_tablespace_adm.file_set;

  cvt_files     dbms_streams_tablespace_adm.file_set;

  -- the dumpfile to import

  dump_file     dbms_streams_tablespace_adm.file;

  dp_job_name   VARCHAR2(30) := NULL;

  -- names of tablespaces that were imported

  ts_names       dbms_streams_tablespace_adm.tablespace_set;

BEGIN

  -- dump file name and location

  dump_file.file_name :=  'dmpfile.dmp';

  dump_file.directory_object := 'STREAMS$DIROBJ$DPDIR';

  -- forming list of datafiles for import

  tbs_files( 1).file_name :=  'o1_mf_app1tbs_cbyvtz0l_.dbf';

  tbs_files( 1).directory_object :=  'STREAMS$DIROBJ$1';

  tbs_files( 2).file_name :=  'o1_mf_app2tbs_cbyvtz1y_.dbf';

  tbs_files( 2).directory_object :=  'STREAMS$DIROBJ$1';

  tbs_files( 3).file_name :=  'o1_mf_idxtbs_cbyvtz52_.dbf';

  tbs_files( 3).directory_object :=  'STREAMS$DIROBJ$1';

  -- import tablespaces

  dbms_streams_tablespace_adm.attach_tablespaces(

    datapump_job_name      => dp_job_name,

    dump_file              => dump_file,

    tablespace_files       => tbs_files,

    converted_files        => cvt_files,

    tablespace_names       => ts_names);

  -- output names of imported tablespaces

  IF ts_names IS NOT NULL AND ts_names.first IS NOT NULL THEN

    FOR i IN ts_names.first .. ts_names.last LOOP

      dbms_output.put_line('imported tablespace '|| ts_names(i));

    END LOOP;

  END IF;

END;

/

-- dropping directory objects

DROP DIRECTORY STREAMS$DIROBJ$1;

DROP DIRECTORY STREAMS$DIROBJ$DPDIR;

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

-- End of sample PL/SQL script

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

 

刪除自動例項

關閉自動例項

資料庫已關閉

資料庫已卸裝

Oracle 例項已關閉

自動例項已刪除

已刪除輔助例項檔案 /u05/tmp/ORCLASM/datafile/o1_mf_temp_cbyvytdt_.tmp

已刪除輔助例項檔案 /u05/tmp/ORCLASM/onlinelog/o1_mf_4_cbyvyqnp_.log

已刪除輔助例項檔案 /u05/tmp/ORCLASM/onlinelog/o1_mf_3_cbyvypkj_.log

已刪除輔助例項檔案 /u05/tmp/ORCLASM/onlinelog/o1_mf_2_cbyvyonl_.log

已刪除輔助例項檔案 /u05/tmp/ORCLASM/onlinelog/o1_mf_1_cbyvykf7_.log

已刪除輔助例項檔案 /u05/tmp/ORCLASM/datafile/o1_mf_sysaux_cbyvtyxm_.dbf

已刪除輔助例項檔案 /u05/tmp/ORCLASM/datafile/o1_mf_undotbs1_cbyvtyz4_.dbf

已刪除輔助例項檔案 /u05/tmp/ORCLASM/datafile/o1_mf_system_cbyvtz5j_.dbf

已刪除輔助例項檔案 /u05/tmp/ORCLASM/datafile/o1_mf_system_cbyvtz00_.dbf

已刪除輔助例項檔案 /u05/tmp/ORCLASM/controlfile/o1_mf_cbyvtc77_.ctl

 

RMAN>

 

[oracle@rhel6_lhr ~]$ cd /u05/tmp

[oracle@rhel6_lhr tmp]$ ll

total 30868

-rw-r----- 1 oracle asmadmin   118784 Feb  1 22:48 dmpfile.dmp

-rw-r--r-- 1 oracle oinstall     2373 Feb  1 22:48 impscrpt.sql

-rw-r----- 1 oracle asmadmin 10493952 Feb  1 22:47 o1_mf_app1tbs_cbyvtz0l_.dbf

-rw-r----- 1 oracle asmadmin 10493952 Feb  1 22:47 o1_mf_app2tbs_cbyvtz1y_.dbf

-rw-r----- 1 oracle asmadmin 10493952 Feb  1 22:47 o1_mf_idxtbs_cbyvtz52_.dbf

drwxr-x--- 5 oracle asmadmin     4096 Feb  1 22:44 ORCLASM

[oracle@rhel6_lhr tmp]$

 

 

一.9  傳輸資料檔案和後設資料到target

這裡需要傳輸轉儲元檔案和資料檔案到目標庫

 

 

一.9.1  檢視目標庫資料檔案位置和目錄

[ZFXDESKDB2:oracle]:/oracle>ORACLE_SID=ora2lhr

[ZFXDESKDB2:oracle]:/oracle>sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 2 13:51:47 2016

 

Copyright (c) 1982, 2013, Oracle.  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

 

SYS@ora2lhr> select name from v$datafile;

 

NAME

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

+DATA/ora2lhr/datafile/system.335.902674033

+DATA/ora2lhr/datafile/sysaux.336.902674033

+DATA/ora2lhr/datafile/undotbs1.337.902674033

+DATA/ora2lhr/datafile/users.338.902674033

+DATA/ora2lhr/datafile/example.348.902674109

 

SYS@ora2lhr> set line 9999

SYS@ora2lhr> col directory_name for a28

SYS@ora2lhr> col directory_path for a100

SYS@ora2lhr> select directory_name,directory_path from dba_directories;

 

DIRECTORY_NAME               DIRECTORY_PATH

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

SUBDIR                       /oracle/app/oracle/product/11.2.0/db/demo/schema/order_entry//2002/Sep

SS_OE_XMLDIR                 /oracle/app/oracle/product/11.2.0/db/demo/schema/order_entry/

LOG_FILE_DIR                 /oracle/app/oracle/product/11.2.0/db/demo/schema/log/

MEDIA_DIR                    /oracle/app/oracle/product/11.2.0/db/demo/schema/product_media/

DATA_FILE_DIR                /oracle/app/oracle/product/11.2.0/db/demo/schema/sales_history/

XMLDIR                       /oracle/app/oracle/product/11.2.0/db/rdbms/xml

ORACLE_OCM_CONFIG_DIR        /oracle/app/oracle/product/11.2.0/db/ccr/state

DATA_PUMP_DIR                /oracle/app/oracle/admin/ora2lhr/dpdump/

ORACLE_OCM_CONFIG_DIR2       /oracle/app/oracle/product/11.2.0/db/ccr/state

 

9 rows selected.

 

SYS@ora2lhr>

SYS@ora2lhr>

 

一.9.2  拷貝檔案到目標庫相應位置並修改許可權

 

wpsF707.tmp 

 

 

 

 

[ZFXDESKDB2:root]:/>cd /oracle/app/oracle/admin/ora2lhr/dpdump

[ZFXDESKDB2:root]:/oracle/app/oracle/admin/ora2lhr/dpdump>l

total 61728

-rw-r-----    1 root     system       118784 Feb 01 22:48 dmpfile.dmp

-rw-r-----    1 root     system         2373 Feb 01 22:48 impscrpt.sql

-rw-r-----    1 root     system     10493952 Feb 01 22:47 o1_mf_app1tbs_cbyvtz0l_.dbf

-rw-r-----    1 root     system     10493952 Feb 01 22:47 o1_mf_app2tbs_cbyvtz1y_.dbf

-rw-r-----    1 root     system     10493952 Feb 01 22:47 o1_mf_idxtbs_cbyvtz52_.dbf

[ZFXDESKDB2:root]:/oracle/app/oracle/admin/ora2lhr/dpdump>chown oracle:dba ./*

[ZFXDESKDB2:root]:/oracle/app/oracle/admin/ora2lhr/dpdump>l

total 61728

-rw-r-----    1 oracle   dba          118784 Feb 01 22:48 dmpfile.dmp

-rw-r-----    1 oracle   dba            2373 Feb 01 22:48 impscrpt.sql

-rw-r-----    1 oracle   dba        10493952 Feb 01 22:47 o1_mf_app1tbs_cbyvtz0l_.dbf

-rw-r-----    1 oracle   dba        10493952 Feb 01 22:47 o1_mf_app2tbs_cbyvtz1y_.dbf

-rw-r-----    1 oracle   dba        10493952 Feb 01 22:47 o1_mf_idxtbs_cbyvtz52_.dbf

[ZFXDESKDB2:root]:/oracle/app/oracle/admin/ora2lhr/dpdump>

 

 

 

一.10  target端轉換位元組序

 

[ZFXDESKDB2:root]:/oracle/app/oracle/admin/ora2lhr/dpdump>su - oracle

[ZFXDESKDB2:oracle]:/oracle>ORACLE_SID=ora2lhr

 

[ZFXDESKDB2:oracle]:/oracle>echo $ORACLE_SID

ora2lhr

[ZFXDESKDB2:oracle]:/oracle>rman target /

 

Recovery Manager: Release 11.2.0.4.0 - Production on Tue Feb 2 13:57:58 2016

 

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

 

connected to target database: ORA2LHR (DBID=4055514164)

 

RMAN> CONVERT DATAFILE

2> "/oracle/app/oracle/admin/ora2lhr/dpdump/o1_mf_app1tbs_cbyvtz0l_.dbf",

3> "/oracle/app/oracle/admin/ora2lhr/dpdump/o1_mf_app2tbs_cbyvtz1y_.dbf",

4> "/oracle/app/oracle/admin/ora2lhr/dpdump/o1_mf_idxtbs_cbyvtz52_.dbf"

5> TO PLATFORM="AIX-Based Systems (64-bit)"

6> FROM PLATFORM="Linux x86 64-bit"

7> FORMAT '+DATA';

 

Starting conversion at target at 2016-02-02 13:58:02

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=165 device type=DISK

channel ORA_DISK_1: starting datafile conversion

input file name=/oracle/app/oracle/admin/ora2lhr/dpdump/o1_mf_app1tbs_cbyvtz0l_.dbf

converted datafile=+DATA/ora2lhr/datafile/app1tbs.265.902757483

channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting datafile conversion

input file name=/oracle/app/oracle/admin/ora2lhr/dpdump/o1_mf_app2tbs_cbyvtz1y_.dbf

converted datafile=+DATA/ora2lhr/datafile/app2tbs.264.902757485

channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting datafile conversion

input file name=/oracle/app/oracle/admin/ora2lhr/dpdump/o1_mf_idxtbs_cbyvtz52_.dbf

converted datafile=+DATA/ora2lhr/datafile/idxtbs.262.902757485

channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01

Finished conversion at target at 2016-02-02 13:58:06

 

RMAN>

RMAN>

 

 

[ZFXDESKDB2:root]:/oracle/app/oracle/admin/ora2lhr/dpdump>

[ZFXDESKDB2:root]:/>su - grid

[ZFXDESKDB2:grid]:/home/grid>asmcmd

ASMCMD> cd +DATA/ora2lhr/datafile/

ASMCMD> ls

APP1TBS.265.902757483

APP2TBS.264.902757485

EXAMPLE.348.902674109

IDXTBS.262.902757485

SYSAUX.336.902674033

SYSTEM.335.902674033

UNDOTBS1.337.902674033

USERS.338.902674033

ASMCMD> ls -l

Type      Redund  Striped  Time             Sys  Name

DATAFILE  UNPROT  COARSE   FEB 02 13:00:00  Y    APP1TBS.265.902757483

DATAFILE  UNPROT  COARSE   FEB 02 13:00:00  Y    APP2TBS.264.902757485

DATAFILE  UNPROT  COARSE   FEB 02 09:00:00  Y    EXAMPLE.348.902674109

DATAFILE  UNPROT  COARSE   FEB 02 13:00:00  Y    IDXTBS.262.902757485

DATAFILE  UNPROT  COARSE   FEB 02 09:00:00  Y    SYSAUX.336.902674033

DATAFILE  UNPROT  COARSE   FEB 02 09:00:00  Y    SYSTEM.335.902674033

DATAFILE  UNPROT  COARSE   FEB 02 09:00:00  Y    UNDOTBS1.337.902674033

DATAFILE  UNPROT  COARSE   FEB 02 09:00:00  Y    USERS.338.902674033

ASMCMD>

 

 

一.11  target端開始匯入資料

一.11.1  建立source庫的2個使用者並賦許可權

如果不建立使用者會報如下的錯誤:

ORA-39123: Data Pump transportable tablespace job aborted

ORA-29342: user USER_APP1 does not exist in the database

 

 

 

[ZFXDESKDB2:oracle]:/oracle>sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 2 14:08:33 2016

Copyright (c) 1982, 2013, Oracle.  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

 

SYS@ora2lhr> create user user_app1 identified by user_app1;

 

User created.

 

SYS@ora2lhr> create user user_app2 identified by user_app2;

 

User created.

 

SYS@ora2lhr> grant connect , resource to user_app1;

 

Grant succeeded.

 

SYS@ora2lhr> grant connect , resource to user_app2;

 

Grant succeeded.

 

SYS@ora2lhr> exit

Disconnected from 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

[ZFXDESKDB2:oracle]:/oracle>

 

 

一.11.2  開始匯入

 

 

[ZFXDESKDB2:oracle]:/oracle>export ORACLE_SID=ora2lhr

[ZFXDESKDB2:oracle]:/oracle>impdp \'/ as sysdba \' DUMPFILE=dmpfile.dmp DIRECTORY=DATA_PUMP_DIR TRANSPORT_DATAFILES='+DATA/ora2lhr/datafile/APP1TBS.265.902757483','+DATA/ora2lhr/datafile/APP2TBS.264.902757485','+DATA/ora2lhr/datafile/IDXTBS.262.902757485' LOGFILE=impdp_tts_20160202.log

 

Import: Release 11.2.0.4.0 - Production on Tue Feb 2 14:11:57 2016

 

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

Master table "SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded

Starting "SYS"."SYS_IMPORT_TRANSPORTABLE_01":  "/******** AS SYSDBA" DUMPFILE=dmpfile.dmp DIRECTORY=DATA_PUMP_DIR TRANSPORT_DATAFILES=+DATA/ora2lhr/datafile/APP1TBS.265.902757483,+DATA/ora2lhr/datafile/APP2TBS.264.902757485,+DATA/ora2lhr/datafile/IDXTBS.262.902757485 LOGFILE=impdp_tts_20160202.log

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/INDEX_STATISTICS

Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS

Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK

Job "SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Tue Feb 2 14:12:11 2016 elapsed 0 00:00:07

 

[ZFXDESKDB2:oracle]:/oracle>

 

日誌:

Tue Feb 02 14:12:04 2016

DM00 started with pid=45, OS id=25231610, job SYS.SYS_IMPORT_TRANSPORTABLE_01

Tue Feb 02 14:12:06 2016

DW00 started with pid=48, OS id=21430384, wid=1, job SYS.SYS_IMPORT_TRANSPORTABLE_01

Plug in tablespace APP1TBS with datafile

  '+DATA/ora2lhr/datafile/APP1TBS.265.902757483'

Plug in tablespace APP2TBS with datafile

  '+DATA/ora2lhr/datafile/APP2TBS.264.902757485'

Plug in tablespace IDXTBS with datafile

  '+DATA/ora2lhr/datafile/IDXTBS.262.902757485'

 

一.11.3  檢視目標平臺資訊

 

[ZFXDESKDB2:oracle]:/oracle>sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 2 14:13:50 2016

 

Copyright (c) 1982, 2013, Oracle.  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

 

SYS@ora2lhr> select tablespace_name,status from dba_tablespaces;

 

TABLESPACE_NAME                STATUS

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

SYSTEM                         ONLINE

SYSAUX                         ONLINE

UNDOTBS1                       ONLINE

TEMP                           ONLINE

USERS                          ONLINE

EXAMPLE                        ONLINE

APP1TBS                        READ ONLY

APP2TBS                        READ ONLY

IDXTBS                         READ ONLY

 

9 rows selected.

 

SYS@ora2lhr> alter tablespace APP1TBS read write;

 

Tablespace altered.

 

SYS@ora2lhr> alter tablespace APP2TBS read write;

 

Tablespace altered.

 

SYS@ora2lhr> alter tablespace IDXTBS read write;

 

Tablespace altered.

 

SYS@ora2lhr> alter user user_app1 default tablespace app1tbs;

 

User altered.

 

SYS@ora2lhr> alter user user_app2 default tablespace app2tbs;

 

User altered.

 

SYS@ora2lhr>  SELECT d.username,d.default_tablespace FROM dba_users d where d.username like 'USER_%' ;

 

USERNAME                       DEFAULT_TABLESPACE

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

USER_APP2                      APP2TBS

USER_APP1                      APP1TBS

 

SYS@ora2lhr>

 

 

 

一.12  檢視匯入後結果

SYS@ora2lhr> set line 9999 pagesize 9999

SYS@ora2lhr> select * from user_app1.app1_tab;

 

     EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO

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

      7369 SMITH      CLERK           7902 1980-12-17 00:00:00        800                    20

      7499 ALLEN      SALESMAN        7698 1981-02-20 00:00:00       1600        300         30

      7521 WARD       SALESMAN        7698 1981-02-22 00:00:00       1250        500         30

      7566 JONES      MANAGER         7839 1981-04-02 00:00:00       2975                    20

      7654 MARTIN     SALESMAN        7698 1981-09-28 00:00:00       1250       1400         30

      7698 BLAKE      MANAGER         7839 1981-05-01 00:00:00       2850                    30

      7782 CLARK      MANAGER         7839 1981-06-09 00:00:00       2450                    10

      7839 KING       PRESIDENT            1981-11-17 00:00:00       5000                    10

      7844 TURNER     SALESMAN        7698 1981-09-08 00:00:00       1500          0         30

      7900 JAMES      CLERK           7698 1981-12-03 00:00:00        950                    30

      7902 FORD       ANALYST         7566 1981-12-03 00:00:00       3000                    20

      7934 MILLER     CLERK           7782 1982-01-23 00:00:00       1300                    10

 

12 rows selected.

 

SYS@ora2lhr> select * from user_app2.app2_tab;

 

    DEPTNO DNAME          LOC

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

        10 ACCOUNTING     NEW YORK

        20 RESEARCH       DALLAS

        30 SALES          CHICAGO

        40 OPERATIONS     BOSTON

 

SYS@ora2lhr>  select D.owner,D.index_name,D.table_name,D.tablespace_name from dba_indexes d WHERE d.table_name in ('APP1_TAB','APP2_TAB');

 

OWNER                          INDEX_NAME                     TABLE_NAME                     TABLESPACE_NAME

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

USER_APP2                      IDX_DEPT_DNAME                 APP2_TAB                       IDXTBS

USER_APP1                      IDX_EMP_ENAME                  APP1_TAB                       IDXTBS

 

SYS@ora2lhr> SELECT   a.NAME,  b.NAME FROM v$tablespace a , v$datafile b WHERE a.TS#=b.TS#  ;

 

NAME                           NAME

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

SYSTEM                         +DATA/ora2lhr/datafile/system.335.902674033

SYSAUX                         +DATA/ora2lhr/datafile/sysaux.336.902674033

UNDOTBS1                       +DATA/ora2lhr/datafile/undotbs1.337.902674033

USERS                          +DATA/ora2lhr/datafile/users.338.902674033

EXAMPLE                        +DATA/ora2lhr/datafile/example.348.902674109

APP1TBS                        +DATA/ora2lhr/datafile/app1tbs.350.902674809

APP2TBS                        +DATA/ora2lhr/datafile/app2tbs.351.902674809

IDXTBS                         +DATA/ora2lhr/datafile/idxtbs.352.902674811

 

8 rows selected.

 

SYS@ora2lhr>

 

 

至此說明3個表空間已經完全由Linux平臺遷移到AIX平臺上。

 

 

 

 

 

 

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

 

 

一.13  總結

 

到此所有的處理算是基本完畢,過程很簡單,但是不同的場景處理方式有很多種,我們應該學會靈活變通。

 

 

 

一.14  About Me

 

...........................................................................................................................................................................................

本文作者:小麥苗,只專注於資料庫的技術,更注重技術的運用

ITPUB BLOG:http://blog.itpub.net/26736162

本文地址:http://blog.itpub.net/26736162/viewspace-1987953/

本文pdf版:http://yunpan.cn/cdEQedhCs2kFz (提取碼:ed9b)

QQ:642808185 若加QQ請註明所正在讀的文章標題

2016-01-26 10:00~ 2016-02-06 19:00 在中行完成

<版權所有,文章允許轉載,但須以連結方式註明源地址,否則追究法律責任!>

...........................................................................................................................................................................................

 

 

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

相關文章