[oracle@dbserver ~]$ rman target sys/oracle auxiliary sys/oracle@sztech2
Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jul 29 16:16:16 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: SZTECH1 (DBID=3206860853)
connected to auxiliary database: SZTECH2 (not mounted)
RMAN> run{
2> allocate auxiliary channel aux1 device type disk;
3> duplicate target database to sztech2;
4> }
using target database control file instead of recovery catalog
allocated channel: aux1
channel aux1: SID=10 device type=DISK
Starting Duplicate Db at 29-JUL-12
contents of Memory Script:
{
sql clone "alter system set db_name =
''SZTECH1'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''SZTECH2'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''SZTECH1'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''SZTECH2'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 322228224 bytes
Fixed Size 1344708 bytes
Variable Size 213912380 bytes
Database Buffers 100663296 bytes
Redo Buffers 6307840 bytes
allocated channel: aux1
channel aux1: SID=133 device type=DISK
Starting restore at 29-JUL-12
channel aux1: starting datafile backup set restore
channel aux1: restoring control file
channel aux1: reading from backup piece /oracle/app/oracle/fast_recovery_area/SZTECH1/autobackup/2012_07_29/o1_mf_s_789925899_819twd7s_.bkp
channel aux1: piece handle=/oracle/app/oracle/fast_recovery_area/SZTECH1/autobackup/2012_07_29/o1_mf_s_789925899_819twd7s_.bkp tag=TAG20120729T155139
channel aux1: restored backup piece 1
channel aux1: restore complete, elapsed time: 00:00:01
output file name=/oracle/app/oracle/oradata/sztech2/control01.ctl
output file name=/oracle/app/oracle/fast_recovery_area/sztech2/control02.ctl
Finished restore at 29-JUL-12
database mounted
contents of Memory Script:
{
set until scn 1266100;
set newname for datafile 1 to
"/oracle/app/oracle/oradata/sztech2/system01.dbf";
set newname for datafile 2 to
"/oracle/app/oracle/oradata/sztech2/sysaux01.dbf";
set newname for datafile 3 to
"/oracle/app/oracle/oradata/sztech2/undotbs01.dbf";
set newname for datafile 4 to
"/oracle/app/oracle/oradata/sztech2/users01.dbf";
set newname for datafile 5 to
"/oracle/app/oracle/oradata/sztech2/example01.dbf";
restore
clone database
;
}
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
Starting restore at 29-JUL-12
channel aux1: starting datafile backup set restore
channel aux1: specifying datafile(s) to restore from backup set
channel aux1: restoring datafile 00001 to /oracle/app/oracle/oradata/sztech2/system01.dbf
channel aux1: restoring datafile 00002 to /oracle/app/oracle/oradata/sztech2/sysaux01.dbf
channel aux1: restoring datafile 00003 to /oracle/app/oracle/oradata/sztech2/undotbs01.dbf
channel aux1: restoring datafile 00004 to /oracle/app/oracle/oradata/sztech2/users01.dbf
channel aux1: restoring datafile 00005 to /oracle/app/oracle/oradata/sztech2/example01.dbf
channel aux1: reading from backup piece /oracle/app/oracle/fast_recovery_area/SZTECH1/backupset/2012_07_29/o1_mf_nnndf_TAG20120729T154322_819tdtj0_.bkp
channel aux1: piece handle=/oracle/app/oracle/fast_recovery_area/SZTECH1/backupset/2012_07_29/o1_mf_nnndf_TAG20120729T154322_819tdtj0_.bkp tag=TAG20120729T154322
channel aux1: restored backup piece 1
channel aux1: restore complete, elapsed time: 00:03:16
Finished restore at 29-JUL-12
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=789927608 file name=/oracle/app/oracle/oradata/sztech2/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=789927608 file name=/oracle/app/oracle/oradata/sztech2/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=789927608 file name=/oracle/app/oracle/oradata/sztech2/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=789927608 file name=/oracle/app/oracle/oradata/sztech2/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=789927608 file name=/oracle/app/oracle/oradata/sztech2/example01.dbf
contents of Memory Script:
{
set until scn 1266100;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 29-JUL-12
starting media recovery
channel aux1: starting archived log restore to default destination
channel aux1: restoring archived log
archived log thread=1 sequence=75
channel aux1: reading from backup piece /oracle/app/oracle/fast_recovery_area/SZTECH1/backupset/2012_07_29/o1_mf_annnn_TAG20120729T155138_819twblj_.bkp
channel aux1: piece handle=/oracle/app/oracle/fast_recovery_area/SZTECH1/backupset/2012_07_29/o1_mf_annnn_TAG20120729T155138_819twblj_.bkp tag=TAG20120729T155138
channel aux1: restored backup piece 1
channel aux1: restore complete, elapsed time: 00:00:01
archived log file name=/oracle/app/oracle/fast_recovery_area/SZTECH2/archivelog/2012_07_29/o1_mf_1_75_819wl01k_.arc thread=1 sequence=75
channel clone_default: deleting archived log(s)
archived log file name=/oracle/app/oracle/fast_recovery_area/SZTECH2/archivelog/2012_07_29/o1_mf_1_75_819wl01k_.arc RECID=54 STAMP=789927616
media recovery complete, elapsed time: 00:00:05
Finished recover at 29-JUL-12
Oracle instance started
Total System Global Area 322228224 bytes
Fixed Size 1344708 bytes
Variable Size 226495292 bytes
Database Buffers 88080384 bytes
Redo Buffers 6307840 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''SZTECH2'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_name = ''SZTECH2'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 322228224 bytes
Fixed Size 1344708 bytes
Variable Size 226495292 bytes
Database Buffers 88080384 bytes
Redo Buffers 6307840 bytes
allocated channel: aux1
channel aux1: SID=133 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SZTECH2" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/oracle/app/oracle/oradata/sztech2/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/oracle/app/oracle/oradata/sztech2/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/oracle/app/oracle/oradata/sztech2/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/oracle/app/oracle/oradata/sztech2/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"/oracle/app/oracle/oradata/sztech2/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/oracle/app/oracle/oradata/sztech2/sysaux01.dbf",
"/oracle/app/oracle/oradata/sztech2/undotbs01.dbf",
"/oracle/app/oracle/oradata/sztech2/users01.dbf",
"/oracle/app/oracle/oradata/sztech2/example01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /oracle/app/oracle/oradata/sztech2/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/oracle/app/oracle/oradata/sztech2/sysaux01.dbf RECID=1 STAMP=789927646
cataloged datafile copy
datafile copy file name=/oracle/app/oracle/oradata/sztech2/undotbs01.dbf RECID=2 STAMP=789927646
cataloged datafile copy
datafile copy file name=/oracle/app/oracle/oradata/sztech2/users01.dbf RECID=3 STAMP=789927646
cataloged datafile copy
datafile copy file name=/oracle/app/oracle/oradata/sztech2/example01.dbf RECID=4 STAMP=789927646
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=789927646 file name=/oracle/app/oracle/oradata/sztech2/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=789927646 file name=/oracle/app/oracle/oradata/sztech2/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=789927646 file name=/oracle/app/oracle/oradata/sztech2/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=789927646 file name=/oracle/app/oracle/oradata/sztech2/example01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 29-JUL-12
released channel: aux1
RMAN>
1.创建辅助实例的口令文件
$ export ORACLE_SID=sztech2
$ orapwd file=$ORACLE_HOME/dbs/orapwsztech2
2.建立到辅助实例的连接
vi $ORACLE_HOME/network/admin/tnsnames.ora
sztech2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.50)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sztech2)
)
)
建立辅助实例的静态监听.
vi $ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_NAME =sztech2
(ORACLE_HOME = /oracle/app/oracle/product/11.2.0.3/db_1)
(SID_NAME = sztech2)
)
)
重起监听,让新的辅助实例监听生效
$ lsnrctl stop
$ lsnrctl start
$ lsnrctl status
测试一下连接到辅助实例
$ tnsping sztech2
3.建立初始参数
3.1 从源库产生一个文本型的初始参数
$ export ORACLE_SID=sztech1
$ sqlplus /nolog
sql>conn / as sysdba
sql>create pfile='/home/oracle/initsztech2.ora' from spfile;
3.2 修改产生的初始参数(根据需要)
修改后为:
*.audit_file_dest='/oracle/app/oracle/admin/sztech2/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.c,'/oracle/app/oracle/fast_recovery_area/sztech2/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='sztech2'
*.db_recovery_file_dest='/oracle/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.diagnostic_dest='/oracle/app/oracle'
*.job_queue_processes=1000
*.memory_target=320756992
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.resource_manager_plan='APPUSER_PLAN'
sztech2.resource_manager_plan='APPUSER_PLAN'
*.undo_tablespace='UNDOTBS1'
db_file_name_c,'/oracle/app/oracle/oradata/sztech2'
log_file_name_c,'/oracle/app/oracle/oradata/sztech2'
3.3 根据参数,建立相应的目录
$ cp -R /oracle/app/oracle/admin/sztech1 /oracle/app/oracle/admin/sztech2
$ mkdir /oracle/app/oracle/fast_recovery_area/sztech2
$ mkdir /oracle/app/oracle/oradata/sztech2
4. 启动辅助数据库到nomount
$ export ORACLE_SID=sztech2
$ sqlplus /nolog
sql> conn / as sysdba;
sql> startup nomount pfile=/home/oracle/initsztech2.ora;
创建服务参数文件
sql> create spfile from pfile='/home/oracle/initsztech2.ora';
使用新的服务参数文件启动数据库到nomount
sql> shutdown immediate
sql> startup nomount;
5.打开源库
6.确定源库的数据文件备份和归档日志文件备份能够被辅助实例访问.
7. 使用rman 连接到源库和辅助库
$ rman target sys/oracle auxiliary sys/oracle@sztech2
8.执行复制
必须开启一个到辅助数据库的连接通道channel
rman >
run{
allocate auxiliary channel aux1 device type disk;
duplicate target database to sztech2;
}
执行...
此处省略 ...
一直到 Finished Duplicate Db at 29-JUL-12
具体日志,见第一楼.
说明:
源库:sztech1
辅助库:sztech2
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28889722/viewspace-1252770/
,如需转载,请注明出处,否则将追究法律责任。