使用RMAN的Transport命令执行transport tablespaces(on the same platform)

RMAN的这个transport命令只是将原有的步骤自动化了一下,实质上没有什么新鲜的内容.


1. Make a backup of the source database


backup database plus archivelog;

实际上只需要:
SYSTEM tablespace
SYSAUX tablespace
Temp tablespace
Tablespaces containing rollback or undo segments
Traget tablesapces
All needed archivelogs
Controlfile


2. Self-Contain check

execute sys.dbms_tts.transport_set_check('TEST1',TRUE);
select * from sys.transport_set_violations;

3. Create Directories for transport and auxiliary destination

mkdir -p /oracle/tmp/transport
mkdir -p /oracle/tmp/aux

4. Create expdp directory

create directory EXPORT_DIR as '/oracle/tmp/export_dir';

5. Prepare an initialization parameter file

### /oracle/tmp/initaux.ora
db_name=SHACOL11
db_unique_name=tspitr_SHACOL11_srsh
control_files=/oracle/tmp/aux/cntrl_tspitr_SHACOL11_srsh.f
db_create_file_dest=/oracle/tmp/aux

compatible=11.1.0.0.0
db_block_size=8192
db_files=200

large_pool_size=1M
shared_pool_size=300M
processes=50


6. Do transport using rman

export ORACLE_SID=shacol11
$ORACLE_HOME/bin/rman target /

run
{
set auxiliary instance parameter file to '/oracle/tmp/initaux.ora';
transport tablespace test1
tablespace destination '/oracle/tmp/transport'
auxiliary destination '/oracle/tmp/aux'
datapump directory EXPORT_DIR
dump file 'transport_test1.dmp'
export log 'transport_test1_export.log'
import script 'transport_test1_imp_script.sql'
#unit scn 99999 | UNTIL RESTORE POINT 'before_upgrade' |UNTIL TIME 'SYSDATE-1'
;
}

Transport命令将启动一个clone数据库,恢复控制文件,mount数据库,然后从备份中恢复auxiliary set,执行TSPITR, 然后open resetlogs, 修改transport tablespaces为read only, 执行expdp,并生成一个attach
用的sql文件,最后打扫卫生结束工作.

最终得到三类文件
数据文件
expdp dump文件
import script

7. Attach

在目标数据库服务器上需要创建用于存放数据文件的transport tablespace destination,拷贝expdp dump文件到
与源端相同的"目录"里,然后执行:

@transport_test1_imp_script.sql


顺便看一下这个script文件的内容:


/*
The following command may be used to import the tablespaces.
Substitute values for and .
impdp directory= dumpfile= 'transport_test1.dmp' transport_datafiles= /oracle/tmp/transport/temp1.dbf
*/
--------------------------------------------------------------
-- Start of sample PL/SQL script for importing the tablespaces
--------------------------------------------------------------
-- creating directory objects
CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/oracle/tmp/transport/';
/* 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 := 'transport_test1.dmp';
dump_file.directory_object := 'EXPORT_DIR';
-- forming list of datafiles for import
tbs_files( 1).file_name := 'temp1.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
--------------------------------------------------------------



8附录: transport命令的输出
--------------------------------------------------------------

executing command: SET auxiliary parameter file
using target database control file instead of recovery catalog

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='vwqj'
using contents of file /oracle/tmp/initaux.ora

initialization parameters used for automatic instance:
db_name=SHACOL11
compatible=11.1.0.0.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_SHACOL11_vwqj
large_pool_size=1M
shared_pool_size=110M
processes=50
ifile=/oracle/tmp/initaux.ora
db_create_file_dest=/oracle/tmp/aux
control_files=/oracle/tmp/aux/cntrl_tspitr_SHACOL11_vwqj.f


starting up automatic instance SHACOL11
Oracle instance started

Total System Global Area 400883712 bytes

Fixed Size 2144744 bytes
Variable Size 343934488 bytes
Database Buffers 50331648 bytes
Redo Buffers 4472832 bytes
Automatic instance created

contents of Memory Script:
{
# set the until clause
set until scn 2854675;
# 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 20-JUN-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=44 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /oracle/flash_recovery_area/SHACOL11/autobackup/2009_06_20/o1_mf_s_690033306_53rqf1l6_.bkp
channel ORA_AUX_DISK_1: piece handle=/oracle/flash_recovery_area/SHACOL11/autobackup/2009_06_20/o1_mf_s_690033306_53rqf1l6_.bkp tag=TAG20090620T115506
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oracle/tmp/aux/cntrl_tspitr_SHACOL11_vwqj.f
Finished restore at 20-JUN-09

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until scn 2854675;
# 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 3 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 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/tmp/transport/temp1.dbf";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxiliary tablespaces
restore clone datafile 1, 3, 2, 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 3 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 5 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace "TEST1", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
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 tempfile 1 to /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 20-JUN-09
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /oracle/tmp/transport/temp1.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oracle/flash_recovery_area/SHACOL11/backupset/2009_06_20/o1_mf_nnndf_TAG20090620T111148_53rnvvbt_.bkp
channel ORA_AUX_DISK_1: piece handle=/oracle/flash_recovery_area/SHACOL11/backupset/2009_06_20/o1_mf_nnndf_TAG20090620T111148_53rnvvbt_.bkp tag=TAG20090620T111148
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 20-JUN-09

datafile 1 switched to datafile copy
input datafile copy RECID=12 STAMP=690038508 file name=/oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_system_53rwg9m6_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=13 STAMP=690038508 file name=/oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_undotbs1_53rwg9r7_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=14 STAMP=690038508 file name=/oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_sysaux_53rwg9oz_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=15 STAMP=690038508 file name=/oracle/tmp/transport/temp1.dbf

sql statement: alter database datafile 1 online

sql statement: alter database datafile 3 online

sql statement: alter database datafile 2 online

sql statement: alter database datafile 5 online

Starting recover at 20-JUN-09
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 45 is already on disk as file /oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_45_53rnx8q0_.arc
archived log for thread 1 with sequence 46 is already on disk as file /oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_46_53ro7zqn_.arc
archived log for thread 1 with sequence 47 is already on disk as file /oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_47_53rqhzk6_.arc
archived log for thread 1 with sequence 48 is already on disk as file /oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_48_53rsdfb9_.arc
archived log for thread 1 with sequence 49 is already on disk as file /oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_49_53rtltrw_.arc
archived log for thread 1 with sequence 50 is already on disk as file /oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_50_53rtrvnf_.arc
archived log file name=/oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_45_53rnx8q0_.arc thread=1 sequence=45
archived log file name=/oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_46_53ro7zqn_.arc thread=1 sequence=46
archived log file name=/oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_47_53rqhzk6_.arc thread=1 sequence=47
archived log file name=/oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_48_53rsdfb9_.arc thread=1 sequence=48
archived log file name=/oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_49_53rtltrw_.arc thread=1 sequence=49
archived log file name=/oracle/flash_recovery_area/SHACOL11/archivelog/2009_06_20/o1_mf_1_50_53rtrvnf_.arc thread=1 sequence=50
media recovery complete, elapsed time: 00:00:03
Finished recover at 20-JUN-09

database opened

contents of Memory Script:
{
#mark read only the tablespace that will be exported
sql clone "alter tablespace TEST1 read only";
# export the tablespaces in the recovery set
host 'expdp userid=
'********'
transport_tablespaces= TEST1 dumpfile=
transport_test1.dmp directory=
EXPORT_DIR logfile=
transport_test1_export.log';
}
executing Memory Script

sql statement: alter tablespace TEST1 read only


Export: Release 11.1.0.6.0 - 64bit Production on Saturday, 20 June, 2009 13:22:01

Copyright (c) 2003, 2007, Oracle. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining
and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TRANSPORTABLE_01": userid="/********@(DESCRIPTION=(ADDRESS=(PROTOCOL=beq)(PROGRAM=/oracle/product/11.1.0/db_1/bin/oracle)(ARGV0=oraclevwqj)(ARGS=(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq))))(ENVS=ORACLE_SID=vwqj))(CONNECT_DATA=(SID=vwqj))) AS SYSDBA" transport_tablespaces= TEST1 dumpfile=transport_test1.dmp directory=EXPORT_DIR logfile=transport_test1_export.log
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:
/oracle/tmp/export_dir/transport_test1.dmp
******************************************************************************
Datafiles required for transportable tablespace TEST1:
/oracle/tmp/transport/temp1.dbf
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 13:22:22

host command complete
/*
The following command may be used to import the tablespaces.
Substitute values for and .
impdp directory= dumpfile= 'transport_test1.dmp' transport_datafiles= /oracle/tmp/transport/temp1.dbf
*/
--------------------------------------------------------------
-- Start of sample PL/SQL script for importing the tablespaces
--------------------------------------------------------------
-- creating directory objects
CREATE DIRECTORY STREAMS$DIROBJ$1 AS '/oracle/tmp/transport/';
/* 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 := 'transport_test1.dmp';
dump_file.directory_object := 'EXPORT_DIR';
-- forming list of datafiles for import
tbs_files( 1).file_name := 'temp1.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/tmp/aux/cntrl_tspitr_SHACOL11_vwqj.f deleted
auxiliary instance file /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_system_53rwg9m6_.dbf deleted
auxiliary instance file /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_undotbs1_53rwg9r7_.dbf deleted
auxiliary instance file /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_sysaux_53rwg9oz_.dbf deleted
auxiliary instance file /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/datafile/o1_mf_temp_53rwhmhs_.tmp deleted
auxiliary instance file /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/onlinelog/o1_mf_1_53rwhjhr_.log deleted
auxiliary instance file /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/onlinelog/o1_mf_2_53rwhknl_.log deleted
auxiliary instance file /oracle/tmp/aux/TSPITR_SHACOL11_SRSH/onlinelog/o1_mf_3_53rwhlcz_.log deleted

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/100682/viewspace-1023337/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/100682/viewspace-1023337/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值