聊聊Oracle可傳輸表空間(Transportable Tablespace)(下)
最後我們聊聊關於ASM下的TTS使用。應該說,ASM是Oracle在儲存層面的重要元件,也是在軟體層面實現冗餘和平衡IO的關鍵解決方案。對11gR2 RAC而言,ASM是取代裸裝置的重要元件。
應用ASM的一個重要特點是:檔案不再歸屬OS檔案系統管理範疇,而是歸屬Oracle ASM Instance管理。資料檔案的冗餘、IO分散、負載均衡乃至操作都是透過Database Server Instance和ASM Intance協調完成。我們從作業系統中是不能涉及到的。如果要使用TTS,我們需要怎麼處理呢?
8、ASM端配置使用
我們本次遷移的目標是進行Linux平臺之間的遷移,一端Source是ASM儲存,而另一端是使用傳統的檔案系統儲存。
首先是Source環境配置資訊。
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> select name, platform_name from v$database;
NAME PLATFORM_NAME
--------- --------------------------------------------------------------------------------
ORA11GAS Linux IA (32-bit)
SQL> select file_name, tablespace_name from dba_data_files where tablespace_name='TTS_SIMPLE';
FILE_NAME TABLESPACE_NAME
-------------------------------------------------------------------------------- ------------------------------
+DATA/ora11gasm/datafile/tts_simple.267.799910245 TTS_SIMPLE
資料檔案儲存在ASM儲存的+DATA Disk Group中。為了進行試驗,在表空間中建立一些物件。
SQL> create user tts_simple identified by tts_simple default tablespace tts_simple;
User created
SQL> grant resource, connect to tts_simple;
Grant succeeded
SQL> conn tts_simple/tts_simple@ora11gasm
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
Connected as tts_simple
SQL> create table t as select * from all_objects;
Table created
SQL> select count(*) from t;
COUNT(*)
----------
56289
Self Contained檢查。
SQL> exec dbms_tts.transport_set_check('tts_simple',true);
PL/SQL procedure successfully completed
SQL> select * from transport_set_violations;
VIOLATIONS
---------------------------------------------------------------------------
SQL> alter tablespace tts_simple read only;
Tablespace altered
使用expdp匯出後設資料,首先需要建立directory物件。
[root@bspdev /]# ls -l | grep ttstest
drwxr-xr-x 2 oracle oinstall 4096 Nov 21 05:24 ttstest
[root@bspdev /]#
SQL> create directory ttsdmp as '/ttstest';
Directory created
匯出後設資料dmp包。
[oracle@bspdev ttstest]$ expdp userid=\'/ as sysdba\' transport_tablespaces=tts_simple dumpfile=tts_simple.dmp directory=ttsdmp transport_full_check=y
Export: Release 11.2.0.3.0 - Production on Wed Nov 21 05:31:04 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/******** AS SYSDBA" transport_tablespaces=tts_simple dumpfile=tts_simple.dmp directory=ttsdmp transport_full_check=y
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TRANSPORTABLE_01 is:
/ttstest/tts_simple.dmp
******************************************************************************
Datafiles required for transportable tablespace TTS_SIMPLE:
+DATA/ora11gasm/datafile/tts_simple.267.799910245
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 05:31:49
下面是一個實驗的關鍵步驟,就是複製出資料檔案。在傳統的檔案系統中,我們可以直接使用FTP/SFTP將資料檔案複製到目標Target端。但是在ASM情況下,我們作業系統的命令是不管用的。
問題的核心問題就是,如何從ASM Diskgroup中將資料檔案複製到檔案系統中。目前我們有兩種方法:
ü 一種是傳統的做法,就是利用RMAN的backup as copy方式,將資料檔案原封不動的複製到檔案系統中;
ü 在11g中,ASM命令列工具asmcmd提供了cp命令,支援ASM和檔案系統之間的複製操作;
我們實驗選擇RMAN方法。
[oracle@bspdev ttstest]$ rman nocatalog
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Nov 21 05:32:23 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target /
connected to target database: ORA11GAS (DBID=2390045008)
using target database control file instead of recovery catalog
RMAN> backup as copy tablespace tts_simple format '/ttstest/%U';
Starting backup at 21-NOV-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=+DATA/ora11gasm/datafile/tts_simple.267.799910245
output file name=/ttstest/data_D-ORA11GAS_I-2390045008_TS-TTS_SIMPLE_FNO-6_0bnqrccg tag=TAG20121121T055216 RECID=3 STAMP=799912337
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 21-NOV-12
Starting Control File and SPFILE Autobackup at 21-NOV-12
piece handle=+RECO/ora11gasm/autobackup/2012_11_21/s_799912339.273.799912341 comment=NONE
Finished Control File and SPFILE Autobackup at 21-NOV-12
RMAN>
我們就可以在檔案系統中找到備份檔案。
[oracle@bspdev ttstest]$ ls -l
total 10376
-rw-r----- 1 oracle asmadmin 10493952 Nov 21 05:52 data_D-ORA11GAS_I-2390045008_TS-TTS_SIMPLE_FNO-6_0bnqrccg
-rw-r--r-- 1 oracle asmadmin 1201 Nov 21 05:31 export.log
-rw-r----- 1 oracle asmadmin 106496 Nov 21 05:31 tts_simple.dmp
[oracle@bspdev ttstest]$
使用mv命令進行重新命名。
[oracle@bspdev ttstest]$ mv data_D-ORA11GAS_I-2390045008_TS-TTS_SIMPLE_FNO-6_0bnqrccg tts_simple01.dbf
[oracle@bspdev ttstest]$ ls -l
total 10376
-rw-r--r-- 1 oracle asmadmin 1201 Nov 21 05:31 export.log
-rw-r----- 1 oracle asmadmin 10493952 Nov 21 05:52 tts_simple01.dbf
-rw-r----- 1 oracle asmadmin 106496 Nov 21 05:31 tts_simple.dmp
[oracle@bspdev ttstest]$
9、目標環境還原
我們選擇將TTS還原到非ASM的Linux平臺上。首選需要使用FTP/SFTP將dmp後設資料和資料檔案複製到Target環境上。
[root@bspdev ~]# cd /
[root@bspdev /]# mkdir ttstest
[root@bspdev /]# chown oracle:oinstall ttstest/
[root@bspdev /]# su - oracle
[oracle@bspdev ~]$ cd /ttstest/
[oracle@bspdev ttstest]$ ls -l
total 0
[oracle@bspdev ttstest]$ pwd
/ttstest
[oracle@bspdev ttstest]$
--複製結束
[oracle@bspdev ttstest]$ ls -l
total 10376
-rw-r--r-- 1 oracle oinstall 1201 Nov 21 06:14 export.log
-rw-r--r-- 1 oracle oinstall 10493952 Nov 21 06:14 tts_simple01.dbf
-rw-r--r-- 1 oracle oinstall 106496 Nov 21 06:14 tts_simple.dmp
將資料檔案歸位,並且建立directory物件,用於進行Metadata還原。
[oracle@bspdev ttstest]$ cp tts_simple01.dbf /u01/oradata/WILSON/datafile/
[oracle@bspdev ttstest]$ cd /u01/oradata/WILSON/datafile/
[oracle@bspdev datafile]$ ls -l
total 1930836
-rw-r----- 1 oracle oinstall 104865792 Nov 21 06:11 o1_mf_example_7xt46m9x_.dbf
(篇幅原因,省略部分……)
-rw-r----- 1 oracle oinstall 110108672 Nov 21 06:17 o1_mf_undotbs1_7xt3yzl5_.dbf
-rw-r----- 1 oracle oinstall 15736832 Nov 21 06:11 o1_mf_users_805nxydh_.dbf
-rw-r--r-- 1 oracle oinstall 10493952 Nov 21 06:17 tts_simple01.dbf
[oracle@bspdev datafile]$ pwd
/u01/oradata/WILSON/datafile
--Sqlplus命令
SQL> create directory ttsdmp as '/ttstest';
Directory created
SQL> create user tts_simple identified by tts_simple;
User created
SQL> grant connect, resource to tts_simple;
Grant succeeded
還原後設資料資訊。
[oracle@bspdev ttstest]$ impdp userid=\'/ as sysdba\' directory=ttsdmp dumpfile=tts_simple.dmp transport_datafiles='/u01/oradata/WILSON/datafile/tts_simple01.dbf'
Import: Release 11.2.0.1.0 - Production on Wed Nov 21 06:22:43 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TRANSPORTABLE_01": userid="/******** AS SYSDBA" directory=ttsdmp dumpfile=tts_simple.dmp transport_datafiles=/u01/oradata/WILSON/datafile/tts_simple01.dbf
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYS"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at 06:23:01
SQL> select file_name, tablespace_name from dba_data_files where tablespace_name like 'TTS%';
FILE_NAME TABLESPACE_NAME
-------------------------------------------------------------------------------- ------------------------------
/u01/oradata/WILSON/datafile/tts_simple01.dbf TTS_SIMPLE
SQL> alter tablespace tts_simple read write;
Tablespace altered
SQL> select count(*) from tts_simple.t;
COUNT(*)
----------
56289
10、More Complex Cases
上面的系列,我們已經介紹了使用TTS的一些基本場景和處理方法。當然,在實際工作中可以會遇到更加複雜的場景。比如,從RAC環境下將一個ASM儲存的表空間遷移到異平臺中一個ASM的伺服器上。
在官方的解決方案中,有幾個需要注意的細節。
首先就是後設資料匯出,使用expdp匯出的時候,我們建立的directory可以是ASM磁碟組目錄。但是,Expdp的日誌卻只能存放在檔案系統中,所以需要額外的directory物件。
其次就是傳輸。Oracle推薦使用dbms_file_transfer.put_file方法將檔案從一個ASM傳出到另一個ASM或者檔案系統。
如果是進行平臺轉換,要注意不要使用dbms_file_transfer進行傳輸。因為目前的Oracle版本中,這個包方法還不能支援平臺間檔案的傳輸。
11、結論
TTS為稱為最快的資料遷移方法,因為我們不需要對資料進行轉換,只需要消耗網路傳輸檔案的時間。但是,TTS針對那些很空的表空間來說,不是一件好方法。例如,一個表空間包括兩個檔案,佔到2G空間,但是內部的有效資料只有10M。消耗2G網路流量顯然不是好方法。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2145047/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【TABLESPACE】Oracle表空間最佳實踐Oracle
- 【TABLESPACE】Oracle 表空間結構說明Oracle
- 【XTTS】Oracle傳輸表空間xtts增量方式TTSOracle
- Tablespace表空間刪除
- MySQL 傳輸表空間MySql
- 聊聊Oracle表空間Offline的三種引數(下)Oracle
- mysql之 表空間傳輸MySql
- 完全可傳輸的匯出/匯入(full transportable export/import)ExportImport
- 聊聊Oracle表空間Offline的三種引數(上)Oracle
- 聊聊Oracle表空間Offline的三種引數(中)Oracle
- Oracle表空間Oracle
- oracle 表空間Oracle
- ORA-1653: unable to extend table by 1024 in tablespace(oracle表空間滿了的解決方案)Oracle
- 【XTTS】使用XTTS傳輸表空間將Oracle11.2.0.4資料遷移至Oracle19CTTSOracle
- 增加oracle表空間Oracle
- oracle temp 表空間Oracle
- oracle 表移動表空間Oracle
- Oracle表移動表空間Oracle
- MySQL傳輸表空間的簡單使用方法MySql
- Oracle11g新增檢視查詢表空間使用率DBA_TABLESPACE_USAGE_METRICSOracle
- oracle建立使用者,表空間,臨時表空間,分配許可權步驟詳解Oracle
- oracle表空間的整理Oracle
- Oracle 批量建表空間Oracle
- Oracle清理SYSAUX表空間OracleUX
- 用傳輸表空間跨平臺遷移資料
- 11g-Reduce Transportable Tablespace Downtime using XTTS (Doc ID 1389592.1)TTS
- Oracle Temp 表空間切換Oracle
- Oracle 表空間增加檔案Oracle
- Oracle OCP(49):表空間管理Oracle
- Oracle表空間收縮方案Oracle
- Oracle RMAN 表空間恢復Oracle
- Oracle新建使用者、表空間、表Oracle
- oracle建立臨時表空間和資料表空間以及刪除Oracle
- Oracle資料庫遷移 - 異構傳輸表空間TTS HP-UX遷移至Redhat Linux 7.7Oracle資料庫TTSRedhatLinux
- Oracle的表空間quota詳解Oracle
- oracle臨時表空間相關Oracle
- oracle sql 表空間利用率OracleSQL
- Oracle OCP(47):表空間的建立Oracle
- 【Oracle 恢復表空間】 實驗Oracle