2.1.4) 启动辅助实例
startup nomount
2.1.5) 配置监听和网络服务名
cd $Oracle_HOME/network/admin
vi listener.ora
vi tnsnames.ora
2.2) 启动目标数据库到MOUNT或OPEN模式
startup
2.3) 验证备份
rman target /
connected to target database: PROD (DBID=251814023)
list backup of database;
using target database control file instead of recovery catalog
specification does not match any backup in the repository
2.4) 新作备份--曾经尝试用压缩备份compressed backupset,但是后面做duplicate的时候报错无法找到备份的数据文件,因此改用不压缩的备份集方式
rman target /
RMAN> backup as backupset full database plus archivelog;
RMAN> list backupset of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 680.90M DISK 00:00:51 05-APR-14
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20140405T120005
Piece Name: /home/oracle/flash/PROD/backupset/2014_04_05/o1_mf_nnndf_TAG20140405T120005_9myzy6yw_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 698762 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/system01.dbf
2 Full 698762 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf
3 Full 698762 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf
4 Full 698762 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/tuning_tbs01.dbf
5 Full 698762 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/DATA01.dbf
6 Full 698762 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/test_tbs01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 681.62M DISK 00:00:47 05-APR-14
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20140405T133552
Piece Name: /home/oracle/flash/PROD/backupset/2014_04_05/o1_mf_nnndf_TAG20140405T133552_9mz5kr7j_.bkp
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 701641 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/system01.dbf
2 Full 701641 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf
3 Full 701641 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf
4 Full 701641 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/tuning_tbs01.dbf
5 Full 701641 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/DATA01.dbf
6 Full 701641 05-APR-14 /u01/app/oracle/oradata/PROD/disk1/test_tbs01.dbf
2.5) 执行复制
2.5.1) 连接目标库和辅助实例
rman target sys/oracle@prod_131 auxiliary sys/oracle@proddup1_131
[oracle@oelr5u8-1 admin]$ rman target sys/oracle@prod_131 auxiliary sys/oracle@proddup1_131
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Apr 5 13:13:13 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD (DBID=251814023)
connected to auxiliary database: PRODDUP1 (not mounted)
2.5.2) 执行DUPLICATE命令
duplicate target database to PRODDUP1;
Starting Duplicate Db at 05-APR-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''PROD'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''PRODDUP1'' 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 = ''PROD'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''PRODDUP1'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 732352512 bytes
Fixed Size 1339036 bytes
Variable Size 494928228 bytes
Database Buffers 230686720 bytes
Redo Buffers 5398528 bytes
Starting restore at 05-APR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=133 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 /home/oracle/flash/PROD/backupset/2014_04_05/o1_mf_ncsnf_TAG20140405T133552_9mz5mkrc_.bkp
channel ORA_AUX_DISK_1: piece handle=/home/oracle/flash/PROD/backupset/2014_04_05/o1_mf_ncsnf_TAG20140405T133552_9mz5mkrc_.bkp tag=TAG20140405T133552
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/PRODDUP1/disk1/control01.ctl
output file name=/u01/app/oracle/oradata/PRODDUP1/disk2/control02.ctl
output file name=/u01/app/oracle/oradata/PRODDUP1/disk3/control03.ctl
Finished restore at 05-APR-14
database mounted
contents of Memory Script:
{
set until scn 701666;
set newname for datafile 1 to
"/u01/app/oracle/oradata/PRODDUP1/disk1/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/PRODDUP1/disk1/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/PRODDUP1/disk1/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/PRODDUP1/disk1/tuning_tbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/PRODDUP1/disk1/DATA01.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/PRODDUP1/disk1/test_tbs01.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
executing command: SET NEWNAME
Starting restore at 05-APR-14
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 /u01/app/oracle/oradata/PRODDUP1/disk1/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/PRODDUP1/disk1/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/PRODDUP1/disk1/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/PRODDUP1/disk1/tuning_tbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/PRODDUP1/disk1/DATA01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/PRODDUP1/disk1/test_tbs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/flash/PROD/backupset/2014_04_05/o1_mf_nnndf_TAG20140405T133552_9mz5kr7j_.bkp
channel ORA_AUX_DISK_1: piece handle=/home/oracle/flash/PROD/backupset/2014_04_05/o1_mf_nnndf_TAG20140405T133552_9mz5kr7j_.bkp tag=TAG20140405T133552
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:37
Finished restore at 05-APR-14
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=844091028 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=844091028 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=844091028 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=844091028 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/tuning_tbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=844091028 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/DATA01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=12 STAMP=844091028 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/test_tbs01.dbf
contents of Memory Script:
{
set until scn 701666;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 05-APR-14
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 23 is already on disk as file /home/oracle/arch/1_23_839975687.dbf
archived log file name=/home/oracle/arch/1_23_839975687.dbf thread=1 sequence=23
media recovery complete, elapsed time: 00:00:01
Finished recover at 05-APR-14
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''PRODDUP1'' 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
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 732352512 bytes
Fixed Size 1339036 bytes
Variable Size 494928228 bytes
Database Buffers 230686720 bytes
Redo Buffers 5398528 bytes
sql statement: alter system set db_name = ''PRODDUP1'' 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 732352512 bytes
Fixed Size 1339036 bytes
Variable Size 494928228 bytes
Database Buffers 230686720 bytes
Redo Buffers 5398528 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PRODDUP1" RESETLOGS ARCHIVELOG
MAXLOGFILES 30
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 2
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/PRODDUP1/disk1/redo101.log', '/u01/app/oracle/oradata/PRODDUP1/disk2/redo102.log', '/u01/app/oracle/oradata/PRODDUP1/disk3/redo103.log' ) SIZE 100 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/PRODDUP1/disk1/redo201.log', '/u01/app/oracle/oradata/PRODDUP1/disk2/redo202.log', '/u01/app/oracle/oradata/PRODDUP1/disk3/redo203.log' ) SIZE 100 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/PRODDUP1/disk1/redo301.log', '/u01/app/oracle/oradata/PRODDUP1/disk2/redo302.log', '/u01/app/oracle/oradata/PRODDUP1/disk3/redo303.log' ) SIZE 100 M REUSE
DATAFILE
'/u01/app/oracle/oradata/PRODDUP1/disk1/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/PRODDUP1/disk1/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/PRODDUP1/disk1/sysaux01.dbf",
"/u01/app/oracle/oradata/PRODDUP1/disk1/undotbs01.dbf",
"/u01/app/oracle/oradata/PRODDUP1/disk1/tuning_tbs01.dbf",
"/u01/app/oracle/oradata/PRODDUP1/disk1/DATA01.dbf",
"/u01/app/oracle/oradata/PRODDUP1/disk1/test_tbs01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/PRODDUP1/disk1/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PRODDUP1/disk1/sysaux01.dbf RECID=1 STAMP=844091049
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PRODDUP1/disk1/undotbs01.dbf RECID=2 STAMP=844091049
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PRODDUP1/disk1/tuning_tbs01.dbf RECID=3 STAMP=844091049
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PRODDUP1/disk1/DATA01.dbf RECID=4 STAMP=844091049
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PRODDUP1/disk1/test_tbs01.dbf RECID=5 STAMP=844091049
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=844091049 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=844091049 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=844091049 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/tuning_tbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=844091049 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/DATA01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=844091049 file name=/u01/app/oracle/oradata/PRODDUP1/disk1/test_tbs01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 05-APR-14
2.6) 验证结果
[oracle@oelr5u8-1 arch]$ sqlplus sys/oracle@proddup1_131 as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Apr 5 13:47:34 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning and Oracle Label Security options
SYS@proddup1_131>select name from v$tablespace;
NAME
------------------------------
SYSTEM
TEMPTS1
SYSAUX
UNDOTBS1
TUNING_TBS
DATA
TEST_TBS
7 rows selected.
SYS@proddup1_131>select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PRODDUP1/disk1/system01.dbf
/u01/app/oracle/oradata/PRODDUP1/disk1/sysaux01.dbf
/u01/app/oracle/oradata/PRODDUP1/disk1/undotbs01.dbf
/u01/app/oracle/oradata/PRODDUP1/disk1/tuning_tbs01.dbf
/u01/app/oracle/oradata/PRODDUP1/disk1/DATA01.dbf
/u01/app/oracle/oradata/PRODDUP1/disk1/test_tbs01.dbf
6 rows selected.
2.7) 同步duplicate数据库
将Duplicate数据库,即上面的PRODDUP1,启动到NOMOUNT状态下,再通过rman连接目标和辅助实例,重新执行duplicate命令即可。
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
