as a prerequest for the duplicate database command is set log_file_name_convert and db_file_name_convert parameter for the auxiliary database init.ora file .
another prerequest is modify the listener.ora file : that's because the auxiliary database is in nomount state before issue the duplicate target command.
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=db)
(ORACLE_HOME=/u01/oracle/product/database)
)
)
the last prereqeust is there must be an existing backup .
[oracle@ocm dbs]$ rman target / auxiliary sys/oracle@db
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Apr 23 12:12:28 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: REPDB (DBID=921033172)
connected to auxiliary database: DB (not mounted)
RMAN> duplicate target database to db;
Starting Duplicate Db at 23-APR-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=48 devtype=DISK
contents of Memory Script:
{
set until scn 177211;
set newname for datafile 1 to
"/u01/oracle/oradata/db/system01.dbf";
set newname for datafile 2 to
"/u01/oracle/oradata/db/undotbs01.dbf";
set newname for datafile 3 to
"/u01/oracle/oradata/db/sysaux01.dbf";
set newname for datafile 4 to
"/u01/oracle/oradata/db/rman.dbf";
restore
check readonly
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
Starting restore at 23-APR-13
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 /u01/oracle/oradata/db/system01.dbf
restoring datafile 00002 to /u01/oracle/oradata/db/undotbs01.dbf
restoring datafile 00003 to /u01/oracle/oradata/db/sysaux01.dbf
restoring datafile 00004 to /u01/oracle/oradata/db/rman.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/rman/clonedb_06o7q1f1_1_1.dbf
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/oracle/rman/clonedb_06o7q1f1_1_1.dbf tag=TAG20130423T121113
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:46
Finished restore at 23-APR-13
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DB" RESETLOGS ARCHIVELOG
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/oracle/oradata/db/redo01.log' ) SIZE 10 M REUSE,
GROUP 2 ( '/u01/oracle/oradata/db/redo02.log' ) SIZE 10 M REUSE,
GROUP 3 ( '/u01/oracle/oradata/db/redo03.log' ) SIZE 10 M REUSE
DATAFILE
'/u01/oracle/oradata/db/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=813500009 filename=/u01/oracle/oradata/db/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=813500009 filename=/u01/oracle/oradata/db/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=813500009 filename=/u01/oracle/oradata/db/rman.dbf
contents of Memory Script:
{
set until scn 177211;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 23-APR-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=48 devtype=DISK
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=52
channel ORA_AUX_DISK_1: reading from backup piece /u01/oracle/product/database/dbs/07o7q1ge_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/oracle/product/database/dbs/07o7q1ge_1_1 tag=TAG20130423T121158
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archive log filename=/u01/oracle/product/database/dbs/arch1_52_813492308.dbf thread=1 sequence=52
channel clone_default: deleting archive log(s)
archive log filename=/u01/oracle/product/database/dbs/arch1_52_813492308.dbf recid=1 stamp=813500012
media recovery complete, elapsed time: 00:00:01
Finished recover at 23-APR-13
contents of Memory Script:
{
shutdown clone;
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 314572800 bytes
Fixed Size 1219160 bytes
Variable Size 96470440 bytes
Database Buffers 213909504 bytes
Redo Buffers 2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DB" RESETLOGS ARCHIVELOG
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/oracle/oradata/db/redo01.log' ) SIZE 10 M REUSE,
GROUP 2 ( '/u01/oracle/oradata/db/redo02.log' ) SIZE 10 M REUSE,
GROUP 3 ( '/u01/oracle/oradata/db/redo03.log' ) SIZE 10 M REUSE
DATAFILE
'/u01/oracle/oradata/db/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/oracle/oradata/db/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/oracle/oradata/db/undotbs01.dbf";
catalog clone datafilecopy "/u01/oracle/oradata/db/sysaux01.dbf";
catalog clone datafilecopy "/u01/oracle/oradata/db/rman.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/oracle/oradata/db/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u01/oracle/oradata/db/undotbs01.dbf recid=1 stamp=813500021
cataloged datafile copy
datafile copy filename=/u01/oracle/oradata/db/sysaux01.dbf recid=2 stamp=813500021
cataloged datafile copy
datafile copy filename=/u01/oracle/oradata/db/rman.dbf recid=3 stamp=813500021
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=813500021 filename=/u01/oracle/oradata/db/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=813500021 filename=/u01/oracle/oradata/db/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=813500021 filename=/u01/oracle/oradata/db/rman.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 23-APR-13
RMAN>