[oracle@lucky ~]$ rman target sys/oracle@PROD1 auxiliary sys/oracle@PROD2
//1.When you connect RMAN to the source database as TARGET, you must specify a password, even if RMAN uses operating system authentication.
//2.The source database and auxiliary instances must use the same SYSDBA password, which means that both instances must have password files. You can create the password file with a single password so you can start the auxiliary instance and enable the source
database to connect to it.
Recovery Manager: Release 11.2.0.1.0 - Production on Thu Apr 7 10:30:22 2016
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: PROD1 (DBID=2129277974)
connected to auxiliary database: PROD2 (not mounted)
DUPLICATE TARGET DATABASE TO PROD2 FROM ACTIVE DATABASE
DB_FILE_NAME_CONVERT ('u01/app/oracle/oradata/PROD1/','u01/app/oracle/oradata/PROD2/')
LOGFILE
GROUP 1 ('/u01/app/oracle/oradata/PROD2/redo01_1.f',
'/u01/app/oracle/oradata/PROD2/redo01_2.f') SIZE 4M,
GROUP 2 ('/u01/app/oracle/oradata/PROD2/redo02_1.f',
'/u01/app/oracle/oradata/PROD2/redo02_2.f') SIZE 4M,
GROUP 3 ('/u01/app/oracle/oradata/PROD2/redo03_1.f',
9> '/u01/app/oracle/oradata/PROD2/redo03_2.f') SIZE 4M REUSE;
//DB_FILE_NAME_CONVERT可以在参数文件中指定,也可以在duplicate中指定
//LOG_FILE_NAME_CONVERT只能在参数文件中指定
//Duplication with Oracle Managed Files
If the source database files are in the Oracle Managed Files (OMF) format, then you cannot use the DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT initialization parameters or the fileNameConversionSpec clause to generate new OMF
file names for the duplicate database.
If you do not follow this rule, the new OMF files generated from these three methods can cause problems. For more information on OMF names, see the "Considerations When Renaming OMF Auxiliary Set Files in TSPITR" in the Oracle Database
Backup and Recovery User's Guide
The only exception to this rule is when changing only an ASM disk group name. Assume that source data files and online redo log files are stored in ASM disk group +SOURCEDSK. You want to store the duplicate database files in ASM
disk group +DUPDSK. In this case, you can set the initialization parameters as follows:
DB_FILE_NAME_CONVERT = ("+SOURCEDSK","+DUPDSK")
LOG_FILE_NAME_CONVERT = ("+SOURCEDSK","+DUPDSK")
RMAN uses DB_FILE_NAME_CONVERT or LOG_FILE_NAME_CONVERT to convert the disk group name, and then generates a new, valid file name based on the converted disk group name.
You have the following other supported options for naming data files when the source files are in the Oracle Managed Files format:
Use SET NEWNAME to specify names for individual data files.
Set DB_FILE_CREATE_DEST to make all data files of the new database Oracle-managed files, except the files for which SET NEWNAME is used. You should not set DB_FILE_NAME_CONVERT if you set DB_FILE_CREATE_DEST.
Supported options for naming online redo logs duplicated from Oracle-managed files are DB_CREATE_FILE_DEST, DB_RECOVERY_FILE_DEST, or DB_CREATE_ONLINE_LOG_DEST_n.
Starting Duplicate Db at 07-APR-16
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=129 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''PROD1'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''PROD2'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u01/app/oracle/oradata/PROD2/control01.ctl';
restore clone controlfile to '/u01/app/oracle/oradata/PROD2/control02.ctl' from
'/u01/app/oracle/oradata/PROD2/control01.ctl';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''PROD1'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''PROD2'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 616566616 bytes
Database Buffers 444596224 bytes
Redo Buffers 5554176 bytes
Starting backup at 07-APR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=71 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PROD1.f tag=TAG20160407T103039 RECID=5 STAMP=908533839
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 07-APR-16
Starting restore at 07-APR-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 07-APR-16
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/u01/app/oracle/oradata/PROD2/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/PROD2/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/PROD2/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/PROD2/USERS.DBF";
set newname for datafile 5 to
"/u01/app/oracle/oradata/PROD2/INDX.DBF";
set newname for datafile 6 to
"/u01/app/oracle/oradata/PROD2/EXAMPLE.DBF";
set newname for datafile 7 to
"/u01/app/oracle/oradata/PROD2/OLTP.DBF";
set newname for datafile 8 to
"/u01/app/oracle/oradata/PROD2/BATCH.DBF";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/PROD2/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/PROD2/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/PROD2/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/PROD2/USERS.DBF" datafile
5 auxiliary format
"/u01/app/oracle/oradata/PROD2/INDX.DBF" datafile
6 auxiliary format
"/u01/app/oracle/oradata/PROD2/EXAMPLE.DBF" datafile
7 auxiliary format
"/u01/app/oracle/oradata/PROD2/OLTP.DBF" datafile
8 auxiliary format
"/u01/app/oracle/oradata/PROD2/BATCH.DBF" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
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 backup at 07-APR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/app/oracle/oradata/PROD1/EXAMPLE.DBF
output file name=/u01/app/oracle/oradata/PROD2/EXAMPLE.DBF tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf
output file name=/u01/app/oracle/oradata/PROD2/system01.dbf tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf
output file name=/u01/app/oracle/oradata/PROD2/sysaux01.dbf tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf
output file name=/u01/app/oracle/oradata/PROD2/undotbs01.dbf tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00008 name=/u01/app/oracle/oradata/PROD1/BATCH.DBF
output file name=/u01/app/oracle/oradata/PROD2/BATCH.DBF tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD1/USERS.DBF
output file name=/u01/app/oracle/oradata/PROD2/USERS.DBF tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00007 name=/u01/app/oracle/oradata/PROD1/OLTP.DBF
output file name=/u01/app/oracle/oradata/PROD2/OLTP.DBF tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD1/INDX.DBF
output file name=/u01/app/oracle/oradata/PROD2/INDX.DBF tag=TAG20160407T103046
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 07-APR-16
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/app/oracle/flash_recovery_area/PROD1/archivelog/2016_04_07/o1_mf_1_15_cjckmt5d_.arc" auxiliary format
"/u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_15_%u_.arc" ;
catalog clone recovery area;
switch clone datafile all;
}
executing Memory Script
Starting backup at 07-APR-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=15 RECID=7 STAMP=908533882
output file name=/u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_15_2jr2e83q_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 07-APR-16
searching for all files in the recovery area
List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_14_29r2e805_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_13_1vr2e51c_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_12_1lr2e440_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_15_2jr2e83q_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_11_1br2e3i8_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_06/o1_mf_1_8_cj9mx7h1_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/flashback/o1_mf_cj9mfzx5_.flb
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_14_29r2e805_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_13_1vr2e51c_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_12_1lr2e440_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_15_2jr2e83q_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_11_1br2e3i8_.arc
File Name: /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_06/o1_mf_1_8_cj9mx7h1_.arc
List of Files Which Where Not Cataloged
=======================================
File Name: /u01/app/oracle/flash_recovery_area/PROD2/flashback/o1_mf_cj9mfzx5_.flb
RMAN-07518: Reason: Foreign database file DBID: 1560297317 Database Name: PROD2
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/USERS.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=9 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/INDX.DBF
datafile 6 switched to datafile copy
input datafile copy RECID=10 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/EXAMPLE.DBF
datafile 7 switched to datafile copy
input datafile copy RECID=11 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/OLTP.DBF
datafile 8 switched to datafile copy
input datafile copy RECID=12 STAMP=908533883 file name=/u01/app/oracle/oradata/PROD2/BATCH.DBF
contents of Memory Script:
{
set until scn 353161;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 07-APR-16
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 15 is already on disk as file /u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_15_2jr2e83q_.arc
archived log file name=/u01/app/oracle/flash_recovery_area/PROD2/archivelog/2016_04_07/o1_mf_1_15_2jr2e83q_.arc thread=1 sequence=15
media recovery complete, elapsed time: 00:00:00
Finished recover at 07-APR-16
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''PROD2'' 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 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 616566616 bytes
Database Buffers 444596224 bytes
Redo Buffers 5554176 bytes
sql statement: alter system set db_name = ''PROD2'' 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 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 616566616 bytes
Database Buffers 444596224 bytes
Redo Buffers 5554176 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PROD2" RESETLOGS ARCHIVELOG
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/PROD2/redo01_1.f', '/u01/app/oracle/oradata/PROD2/redo01_2.f' ) SIZE 4 M ,
GROUP 2 ( '/u01/app/oracle/oradata/PROD2/redo02_1.f', '/u01/app/oracle/oradata/PROD2/redo02_2.f' ) SIZE 4 M ,
GROUP 3 ( '/u01/app/oracle/oradata/PROD2/redo03_1.f', '/u01/app/oracle/oradata/PROD2/redo03_2.f' ) SIZE 4 M REUSE
DATAFILE
'/u01/app/oracle/oradata/PROD2/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/PROD2/temp01.dbf";
set newname for tempfile 2 to
"/u01/app/oracle/oradata/PROD2/TMP1_01_GRP.DBF";
set newname for tempfile 3 to
"/u01/app/oracle/oradata/PROD2/TMP2_01_GRP.DBF";
set newname for tempfile 4 to
"/u01/app/oracle/oradata/PROD2/TMP3_01_GRP.DBF";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/PROD2/sysaux01.dbf",
"/u01/app/oracle/oradata/PROD2/undotbs01.dbf",
"/u01/app/oracle/oradata/PROD2/USERS.DBF",
"/u01/app/oracle/oradata/PROD2/INDX.DBF",
"/u01/app/oracle/oradata/PROD2/EXAMPLE.DBF",
"/u01/app/oracle/oradata/PROD2/OLTP.DBF",
"/u01/app/oracle/oradata/PROD2/BATCH.DBF";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/PROD2/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/PROD2/TMP1_01_GRP.DBF in control file
renamed tempfile 3 to /u01/app/oracle/oradata/PROD2/TMP2_01_GRP.DBF in control file
renamed tempfile 4 to /u01/app/oracle/oradata/PROD2/TMP3_01_GRP.DBF in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD2/sysaux01.dbf RECID=1 STAMP=908533900
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD2/undotbs01.dbf RECID=2 STAMP=908533900
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD2/USERS.DBF RECID=3 STAMP=908533900
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD2/INDX.DBF RECID=4 STAMP=908533900
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD2/EXAMPLE.DBF RECID=5 STAMP=908533900
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD2/OLTP.DBF RECID=6 STAMP=908533900
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD2/BATCH.DBF RECID=7 STAMP=908533900
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=908533900 file name=/u01/app/oracle/oradata/PROD2/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=908533900 file name=/u01/app/oracle/oradata/PROD2/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=908533900 file name=/u01/app/oracle/oradata/PROD2/USERS.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=908533900 file name=/u01/app/oracle/oradata/PROD2/INDX.DBF
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=908533900 file name=/u01/app/oracle/oradata/PROD2/EXAMPLE.DBF
datafile 7 switched to datafile copy
input datafile copy RECID=6 STAMP=908533900 file name=/u01/app/oracle/oradata/PROD2/OLTP.DBF
datafile 8 switched to datafile copy
input datafile copy RECID=7 STAMP=908533900 file name=/u01/app/oracle/oradata/PROD2/BATCH.DBF
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 07-APR-16
RMAN>