RMAN使用备份传输表空间的各种自定义操作(6)

使用初始化参数来对传输表空间命名辅助数据文件
 可以在辅助实例参数文件中使用log_file_name_convert和db_file_name_convert参数来控制辅助实例的联机重做日志和其它数据文件的文件名
[Oracle@oracle11g u02]$ vi initaux.ora

shared_pool_size=150M
control_files=('/u02/transport/control01.ctl')
db_file_name_convert=('/u01/app/oracle/oradata/test/','/u02/transport/')
log_file_name_convert=('/u01/app/oracle/oradata/test/','/u02/transport/')


RMAN> run
2> {
3> set auxiliary instance parameter file to '/u02/initaux.ora';
4> transport tablespace "TSPITR","TEST"
5> tablespace destination '/u02/transport';
}6>

executing command: SET auxiliary parameter file


Creating automatic instance, with SID='psnl'
using contents of file /u02/initaux.ora

initialization parameters used for automatic instance:
db_name=TEST
compatible=10.2.0.5.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_TEST_psnl
sga_target=180M
processes=50
ifile=/u02/initaux.ora
#No auxiliary destination in use
#Use default controlfile


starting up automatic instance TEST

Oracle instance started

Total System Global Area    188743680 bytes

Fixed Size                    1272720 bytes
Variable Size                167773296 bytes
Database Buffers              16777216 bytes
Redo Buffers                  2920448 bytes
Automatic instance created

contents of Memory Script:
{
# set the until clause
set until  scn 1205073;
# 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;';
# resync catalog after controlfile restore
resync catalog;
}
executing Memory Script

executing command: SET until clause

Starting restore at 28-MAR-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=47 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 /u02/c-2168949517-20150326-07
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/c-2168949517-20150326-07 tag=TAG20150326T203351
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u02/transport/control01.ctl
Finished restore at 28-MAR-15

sql statement: alter database mount clone database

sql statement: alter system archive log current

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

starting full resync of recovery catalog
full resync complete

contents of Memory Script:
{
# generated tablespace point-in-time recovery script
# set the until clause
set until  scn 1205073;
# set a destination filename for restore
set newname for datafile  1 to
 "/u02/transport/system01.dbf";
# set a destination filename for restore
set newname for datafile  2 to
 "/u02/transport/undotbs01.dbf";
# set a destination filename for restore
set newname for datafile  3 to
 "/u02/transport/sysaux01.dbf";
# set a destination tempfile
set newname for tempfile  1 to
 "/u02/transport/temp01.dbf";
# set a destination filename for restore
set newname for datafile  6 to
 "/u02/transport/tspitr01.dbf";
# set a destination filename for restore
set newname for datafile  7 to
 "/u02/transport/test01.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, 6, 7;
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  6 online";
#online the datafiles restored or flipped
sql clone "alter database datafile  7 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace  "TSPITR", "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

executing command: SET NEWNAME


Starting restore at 28-MAR-15
using channel ORA_AUX_DISK_1

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 /u02/transport/system01.dbf
restoring datafile 00002 to /u02/transport/undotbs01.dbf
restoring datafile 00003 to /u02/transport/sysaux01.dbf
restoring datafile 00006 to /u02/transport/tspitr01.dbf
restoring datafile 00007 to /u02/transport/test01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/ora_test875392350_1001
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/ora_test875392350_1001 tag=TAG20150326T203229
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:45
Finished restore at 28-MAR-15


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  6 online

sql statement: alter database datafile  7 online

Starting recover at 28-MAR-15
using channel ORA_AUX_DISK_1

starting media recovery

archive log thread 1 sequence 80 is already on disk as file /u02/1_80_870806981.dbf
archive log thread 1 sequence 81 is already on disk as file /u02/1_81_870806981.dbf
archive log thread 1 sequence 82 is already on disk as file /u02/1_82_870806981.dbf
archive log thread 1 sequence 83 is already on disk as file /u02/1_83_870806981.dbf
archive log thread 1 sequence 84 is already on disk as file /u02/1_84_870806981.dbf
archive log thread 1 sequence 85 is already on disk as file /u02/1_85_870806981.dbf
archive log thread 1 sequence 86 is already on disk as file /u02/1_86_870806981.dbf
archive log thread 1 sequence 87 is already on disk as file /u02/1_87_870806981.dbf
archive log thread 1 sequence 88 is already on disk as file /u02/1_88_870806981.dbf
archive log thread 1 sequence 89 is already on disk as file /u02/1_89_870806981.dbf
archive log thread 1 sequence 90 is already on disk as file /u02/1_90_870806981.dbf
archive log thread 1 sequence 91 is already on disk as file /u02/1_91_870806981.dbf
archive log thread 1 sequence 92 is already on disk as file /u02/1_92_870806981.dbf
archive log filename=/u02/1_80_870806981.dbf thread=1 sequence=80
archive log filename=/u02/1_81_870806981.dbf thread=1 sequence=81
archive log filename=/u02/1_82_870806981.dbf thread=1 sequence=82
archive log filename=/u02/1_83_870806981.dbf thread=1 sequence=83
archive log filename=/u02/1_84_870806981.dbf thread=1 sequence=84
archive log filename=/u02/1_85_870806981.dbf thread=1 sequence=85
archive log filename=/u02/1_86_870806981.dbf thread=1 sequence=86
archive log filename=/u02/1_87_870806981.dbf thread=1 sequence=87
archive log filename=/u02/1_88_870806981.dbf thread=1 sequence=88
archive log filename=/u02/1_89_870806981.dbf thread=1 sequence=89
archive log filename=/u02/1_90_870806981.dbf thread=1 sequence=90
archive log filename=/u02/1_91_870806981.dbf thread=1 sequence=91
archive log filename=/u02/1_92_870806981.dbf thread=1 sequence=92
media recovery complete, elapsed time: 00:01:06
Finished recover at 28-MAR-15

database opened

contents of Memory Script:
{
#mark read only the tablespace that will be exported
sql clone "alter tablespace TSPITR read only";
#mark read only the tablespace that will be exported
sql clone "alter tablespace TEST read only";
# create directory for datapump export
sql clone "create or replace directory STREAMS_DIROBJ_DPDIR as ''
/u02/transport''";
# export the tablespaces in the recovery set
host 'expdp userid=\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/10.2.0/db/bin/oracle\)\(ARGV0=oraclepsnl\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=psnl^'\)\)\(CONNECT_DATA=\(SID=psnl\)\)\) as sysdba\" transport_tablespaces=
 TSPITR,
 TEST dumpfile=
dmpfile.dmp directory=
STREAMS_DIROBJ_DPDIR logfile=
explog.log';
}
executing Memory Script

sql statement: alter tablespace TSPITR read only

sql statement: alter tablespace TEST read only

sql statement: create or replace directory STREAMS_DIROBJ_DPDIR as ''/u02/transport''


Export: Release 10.2.0.5.0 - Production on Saturday, 28 March, 2015 20:48:44

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

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.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=/u01/app/oracle/10.2.0/db/bin/oracle)(ARGV0=oraclepsnl)(ARGS=\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\))(ENVS=ORACLE_SID=psnl))(CONNECT_DATA=(SID=psnl))) AS SYSDBA" transport_tablespaces= TSPITR, TEST dumpfile=dmpfile.dmp directory=STREAMS_DIROBJ_DPDIR logfile=explog.log
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
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:
  /u02/transport/dmpfile.dmp
Job "SYS"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 20:49:41

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

Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /u02/transport/control01.ctl deleted
auxiliary instance file /u02/transport/system01.dbf deleted
auxiliary instance file /u02/transport/undotbs01.dbf deleted
auxiliary instance file /u02/transport/sysaux01.dbf deleted
auxiliary instance file /u02/transport/temp01.dbf deleted
auxiliary instance file /u02/transport/redo01.log deleted
auxiliary instance file /u02/transport/redo02.log deleted
auxiliary instance file /u02/transport/redo03.log deleted

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6babcd045422b613ec9318eb94c1f113.html