使用RMAN實現可傳輸的表空間
使用可傳輸的表空間,在拷貝資料檔案時,需要將資料檔案設定為只讀,這對於24小時的系統來說,這是不可能的
使用RMAN,可以在不對主庫造成任何影響的情況下,實現可傳輸的表空間。
該方法主要是通過建立一個auxiliary例項,進行一個TSPITR,然後在auxiliary上將表空間匯出
參見:455593.1
rman target / --源庫
-------------------------------------------------------------------------
RMAN> run {
2> transport tablespace "TEST"
3> Tablespace destination '/oracle/oradata/AUX/tts'
4> Auxiliary destination '/oracle/oradata/AUX/tts'
5> Datapump directory data_pump_dir
6> dump file 'tts_test.dmp'
7> Import script. 'tts_test.imp'
8> Export log 'exp_tts_test.log'
9> UNTIL TIME "to_date('23 4 2009 12:00:00','DD MM YYYY hh24:mi:ss')";
10> }
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time
List of tablespaces expected to have UNDO segments
tablespace SYSTEM
tablespace UNDOTBS1
Creating automatic instance, with SID='zfnl'
initialization parameters used for automatic instance:
db_name=LOGMINER
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_LOGMINER_zfnl
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=/oracle/oradata/AUX/tts
control_files=/oracle/oradata/AUX/tts/cntrl_tspitr_LOGMINER_zfnl.f
starting up automatic instance LOGMINER
Oracle instance started
Total System Global Area 201326592 bytes
Fixed Size 1266584 bytes
Variable Size 146803816 bytes
Database Buffers 50331648 bytes
Redo Buffers 2924544 bytes
Automatic instance created
contents of Memory Script.:
{
# set the until clause
set until time "to_date('23 4 2009 12:00:00','DD MM YYYY hh24:mi:ss')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script
executing command: SET until clause
Starting restore at 23-APR-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=37 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /oracle/flash_recovery_area/LOGMINER/autobackup/2009_04_07/o1_mf_s_683550244_4xojo530_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/oracle/flash_recovery_area/LOGMINER/autobackup/2009_04_07/o1_mf_s_683550244_4xojo530_.bkp tag=TAG20090407T110404
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/oracle/oradata/AUX/tts/cntrl_tspitr_LOGMINER_zfnl.f
Finished restore at 23-APR-09
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
released channel: ORA_AUX_DISK_1
contents of Memory Script.:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until time "to_date('23 4 2009 12:00:00','DD MM YYYY hh24:mi:ss')";
# set an omf destination filename for restore
set newname for clone datafile 1 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 to new;
# set an omf destination filename for restore
set newname for clone datafile 3 to new;
# set an omf destination tempfile
set newname for clone tempfile 1 to new;
# set a destination filename for restore
set newname for datafile 5 to
"/oracle/oradata/AUX/tts/TEST.dbf";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 3, 5;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile 1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 3 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 5 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace "TEST", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack
# of temporary space.
# For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
# datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed temporary file 1 to /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 23-APR-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=40 devtype=DISK
channel ORA_AUX_DISK_1: restoring datafile 00005
input datafile copy recid=21 stamp=683548647 filename=/tmp/tmp.dbf
destination for restore of datafile 00005: /oracle/oradata/AUX/tts/TEST.dbf
channel ORA_AUX_DISK_1: copied datafile copy of datafile 00005
output filename=/oracle/oradata/AUX/tts/TEST.dbf recid=23 stamp=684936468
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_system_%u_.dbf
restoring datafile 00002 to /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_undotbs1_%u_.dbf
restoring datafile 00003 to /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oracle/flash_recovery_area/LOGMINER/backupset/2009_04_06/o1_mf_nnndf_TAG20090406T194141_4xmtmppl_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/oracle/flash_recovery_area/LOGMINER/backupset/2009_04_06/o1_mf_nnndf_TAG20090406T194141_4xmtmppl_.bkp tag=TAG20090406T194141
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 23-APR-09
datafile 1 switched to datafile copy
input datafile copy recid=27 stamp=684936524 filename=/oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_system_4yztdop2_.dbf
datafile 2 switched to datafile copy
input datafile copy recid=28 stamp=684936524 filename=/oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_undotbs1_4yztdosb_.dbf
datafile 3 switched to datafile copy
input datafile copy recid=29 stamp=684936524 filename=/oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_sysaux_4yztdowk_.dbf
datafile 5 switched to datafile copy
input datafile copy recid=30 stamp=684936524 filename=/oracle/oradata/AUX/tts/TEST.dbf
sql statement: alter database datafile 1 online
sql statement: alter database datafile 2 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 5 online
Starting recover at 23-APR-09
using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 5 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_06/o1_mf_1_5_4xmzz10j_.arc
archive log thread 1 sequence 6 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_07/o1_mf_1_6_4xog7ds3_.arc
archive log thread 1 sequence 7 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_7_4xv9swlt_.arc
archive log thread 1 sequence 8 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_8_4xvb45hn_.arc
archive log thread 1 sequence 9 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_9_4xvb4t37_.arc
archive log thread 1 sequence 10 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_10_4xvb58b5_.arc
archive log thread 1 sequence 11 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_11_4xvb5qlt_.arc
archive log thread 1 sequence 12 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_23/o1_mf_1_12_4yzqvjhs_.arc
archive log thread 1 sequence 13 is already on disk as file /oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_23/o1_mf_1_13_4yztdk93_.arc
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_06/o1_mf_1_5_4xmzz10j_.arc thread=1 sequence=5
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_07/o1_mf_1_6_4xog7ds3_.arc thread=1 sequence=6
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_7_4xv9swlt_.arc thread=1 sequence=7
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_8_4xvb45hn_.arc thread=1 sequence=8
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_9_4xvb4t37_.arc thread=1 sequence=9
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_10_4xvb58b5_.arc thread=1 sequence=10
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_09/o1_mf_1_11_4xvb5qlt_.arc thread=1 sequence=11
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_23/o1_mf_1_12_4yzqvjhs_.arc thread=1 sequence=12
archive log filename=/oracle/flash_recovery_area/LOGMINER/archivelog/2009_04_23/o1_mf_1_13_4yztdk93_.arc thread=1 sequence=13
media recovery complete, elapsed time: 00:01:40
Finished recover at 23-APR-09
database opened
contents of Memory Script.:
{
#mark read only the tablespace that will be exported
sql clone "alter tablespace TEST read only";
# export the tablespaces in the recovery set
host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/oracle/product/10.2.0/bin/oracle\)\(ARGV0=oraclezfnl\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=zfnl^'\)\)\(CONNECT_DATA=\(SID=zfnl\)\)\) as sysdba\" transport_tablespaces=
TEST dumpfile=
tts_test.dmp directory=
data_pump_dir logfile=
exp_tts_test.log';
}
executing Memory Script
sql statement: alter tablespace TEST read only
Export: Release 10.2.0.4.0 - Production on Thursday, 23 April, 2009 12:11:08
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/oracle/product/10.2.0/bin/oracle)(ARGV0=oraclezfnl)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=zfnl))(CONNECT_DATA=(SID=zfnl))) AS SYSDBA" transport_tablespaces= TEST dumpfile=tts_test.dmp directory=data_pump_dir logfile=exp_tts_test.log
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
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:
/oracle/oradata/AUX/tts_test.dmp
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 12:11:38
host command complete
/*
The following command may be used to import the tablespaces.
Substitute values for
impdp
*/
--------------------------------------------------------------
-- Start of sample PL/SQL script. for importing the tablespaces
--------------------------------------------------------------
-- creating directory objects
CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/oracle/oradata/AUX/tts/';
/* 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 := 'tts_test.dmp';
dump_file.directory_object := 'data_pump_dir';
-- forming list of datafiles for import
tbs_files( 1).file_name := 'TEST.dbf';
tbs_files( 1).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;
--------------------------------------------------------------
-- End of sample PL/SQL script
--------------------------------------------------------------
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /oracle/oradata/AUX/tts/cntrl_tspitr_LOGMINER_zfnl.f deleted
auxiliary instance file /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_system_4yztdop2_.dbf deleted
auxiliary instance file /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_undotbs1_4yztdosb_.dbf deleted
auxiliary instance file /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_sysaux_4yztdowk_.dbf deleted
auxiliary instance file /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/datafile/o1_mf_temp_4yztl12v_.tmp deleted
auxiliary instance file /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/onlinelog/o1_mf_1_4yztknnm_.log deleted
auxiliary instance file /oracle/oradata/AUX/tts/TSPITR_LOGMINER_ZFNL/onlinelog/o1_mf_3_4yztkpvg_.log deleted
-------------------------------------------------------------------------
[oracle@RMAN AUX]$ pwd
/oracle/oradata/AUX
[oracle@RMAN AUX]$ ls -l
total 104
-rw-r--r-- 1 oracle dba 1361 Apr 23 12:11 exp_tts_test.log --expdp的日誌
drwxr-xr-x 3 oracle dba 4096 Apr 23 12:11 tts
-rw-r----- 1 oracle dba 81920 Apr 23 12:11 tts_test.dmp --expdp的匯出檔案
[oracle@RMAN AUX]$ cd tts
[oracle@RMAN tts]$ ls -l
total 272748
-rw-r----- 1 oracle dba 278994944 Apr 23 12:11 TEST.dbf --匯出的表空間的資料檔案
drwxr-x--- 4 oracle dba 4096 Apr 23 12:07 TSPITR_LOGMINER_ZFNL --在操作時臨時建立的系統表空間,日誌檔案。操作完成後自動刪除
-rw-r--r-- 1 oracle dba 1959 Apr 23 12:11 tts_test.imp --匯入時使用的指令碼
[oracle@RMAN tts]$ cat tts_test.imp
/*
The following command may be used to import the tablespaces.
Substitute values for
impdp
*/
--------------------------------------------------------------
-- Start of sample PL/SQL script. for importing the tablespaces
--------------------------------------------------------------
-- creating directory objects
CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/oracle/oradata/AUX/tts/';
/* 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 := 'tts_test.dmp';
dump_file.directory_object := 'data_pump_dir';
-- forming list of datafiles for import
tbs_files( 1).file_name := 'TEST.dbf';
tbs_files( 1).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;
--------------------------------------------------------------
-- End of sample PL/SQL script
--------------------------------------------------------------
可用impdp或者指令碼來匯入表空間到其他資料庫去
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8242091/viewspace-591532/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 傳輸表空間MySql
- mysql之 表空間傳輸MySql
- MySQL傳輸表空間的簡單使用方法MySql
- Oracle RMAN 表空間恢復Oracle
- 【MOS】如何利用RMAN可傳輸表空間遷移資料庫到不同位元組序的平臺(文件 ID 1983639.1)資料庫
- 【資料遷移】XTTS跨平臺傳輸表空間v3(2.RMAN增量)TTS
- 【XTTS】Oracle傳輸表空間xtts增量方式TTSOracle
- 當使用者無限制使用表空間配額且表空間有足夠空間時出現超出表空間的空間限額
- [20210527]rman與undo表空間備份.txt
- Oracle RMAN備份為什麼會大量使用temp表空間?Oracle
- 用傳輸表空間跨平臺遷移資料
- oracle建立使用者,表空間,臨時表空間,分配許可權步驟詳解Oracle
- 【流式傳輸】使用Spring Boot實現ChatGpt流式傳輸Spring BootChatGPT
- 【資料遷移】XTTS跨平臺傳輸表空間(1.傳統方式)TTS
- 【XTTS】使用XTTS傳輸表空間將Oracle11.2.0.4資料遷移至Oracle19CTTSOracle
- 【分段傳輸】c#使用IAsyncEnumerable實現流式分段傳輸C#
- 【資料遷移】XTTS跨平臺傳輸表空間v4TTS
- 12c – 使用跨平臺增量備份來減少傳輸表空間的停機時間 (文件 ID 2102859.1)
- 12c – 使用跨平臺增量備份來減少傳輸表空間的停機時間 (Doc ID 2102859.1)
- 16、表空間 建立表空間
- Oracle 12C RMAN備份佔用大量臨時表空間Oracle
- Oracle新建使用者、表空間、表Oracle
- 臨時表空間和回滾表空間使用率查詢
- 表空間利用率及表空間的補充
- Oraclc 12C使用不一致備份執行跨平臺傳輸表空間
- KingbaseES的表空間
- 【RMAN】當表空間處於備份狀態時發生了什麼
- 查詢表空間使用情況
- 表空間使用量查詢
- oracle11g 查詢臨時表空間的使用率和正在使用臨時表空間的使用者Oracle
- 表空間TSPITR恢復-實驗
- 【Oracle 恢復表空間】 實驗Oracle
- 【TABLESPACE】Oracle表空間最佳實踐Oracle
- oracle表空間的整理Oracle
- 複製建立已有資料庫使用者、表空間、許可權的指令碼資料庫指令碼
- 【資料遷移】XTTS跨平臺傳輸表空間v3(3.DFT方式)TTS
- 查詢表空間使用情況的指令碼指令碼
- Oracle表空間Oracle
- oracle 表空間Oracle