Sunday, January 9, 2011

use 'duplicate database" command to create standby database without backup

Preparation:
==========================

[oracle@vmxdb06 ~]$ cat /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initdrorcl.ora
drorcl.__db_cache_size=247463936
drorcl.__large_pool_size=4194304
drorcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
drorcl.__shared_pool_size=117440512
*.audit_file_dest='/u01/app/oracle/admin/drorcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/drorcl/control01.ctl','/u01/app/oracle/fast_recovery_area/drorcl/control02.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_domain=''
*.db_file_name_convert='prorcl','drorcl'
*.db_name='prorcl'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=5218762752
*.db_unique_name='DRORCL'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=drorclXDB)'
*.fal_server='prorcl'
*.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=drorcl'
*.log_archive_dest_2='SERVICE=prorcl VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=prorcl'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_file_name_convert='prorcl','drorcl'
*.memory_target=635437056
*.open_cursors=300
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=555
*.standby_file_management='AUTO



[oracle@vmxdb06 ~]$ cat /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.


LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmxdb06.lab.dbaglobe.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = drorcl_dgmgrl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = drorcl)
)
)

ADR_BASE_LISTENER = /u01/app/oracle

[oracle@vmxdb06 ~]$ cat /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

PRORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmxdb05.lab.dbaglobe.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prorcl)
)
)


DRORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmxdb06.lab.dbaglobe.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = drorcl)
)
)

PRORCL_DGMGRL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmxdb05.lab.dbaglobe.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prorcl_dgmgrl)
)
)


DRORCL_DGMGRL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmxdb06.lab.dbaglobe.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = drorcl_dgmgrl)
)
)


Duplication:
==========================


[oracle@vmxdb05 admin]$ rman target / auxiliary sys/ora123@drorcl_dgmgrl

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Jan 9 18:21:39 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: PRORCL (DBID=4067017581)
connected to auxiliary database: PRORCL (not mounted)

RMAN> duplicate target database for standby from active database;

Starting Duplicate Db at 09-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK

contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwprorcl' auxiliary format
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwdrorcl' ;
}
executing Memory Script

Starting backup at 09-JAN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
Finished backup at 09-JAN-11

contents of Memory Script:
{
backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/drorcl/control01.ctl';
restore clone controlfile to '/u01/app/oracle/fast_recovery_area/drorcl/control02.ctl' from
'/u01/app/oracle/oradata/drorcl/control01.ctl';
}
executing Memory Script

Starting backup at 09-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_prorcl.f tag=TAG20110109T182208 RECID=2 STAMP=739995729
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 09-JAN-11

Starting restore at 09-JAN-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 09-JAN-11

contents of Memory Script:
{
sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/drorcl/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/u01/app/oracle/oradata/drorcl/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/drorcl/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/drorcl/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/drorcl/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/drorcl/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/drorcl/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/drorcl/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/drorcl/users01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/drorcl/temp01.dbf in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 09-JAN-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/prorcl/system01.dbf
output file name=/u01/app/oracle/oradata/drorcl/system01.dbf tag=TAG20110109T182219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/prorcl/sysaux01.dbf
output file name=/u01/app/oracle/oradata/drorcl/sysaux01.dbf tag=TAG20110109T182219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:36
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/prorcl/undotbs01.dbf
output file name=/u01/app/oracle/oradata/drorcl/undotbs01.dbf tag=TAG20110109T182219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/prorcl/users01.dbf
output file name=/u01/app/oracle/oradata/drorcl/users01.dbf tag=TAG20110109T182219
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 09-JAN-11

sql statement: alter system archive log current

contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=739995828 file name=/u01/app/oracle/oradata/drorcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=739995828 file name=/u01/app/oracle/oradata/drorcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=739995828 file name=/u01/app/oracle/oradata/drorcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=739995828 file name=/u01/app/oracle/oradata/drorcl/users01.dbf
Finished Duplicate Db at 09-JAN-11

RMAN> exit


Recovery Manager complete.