RMAN Duplicate Database Command

Primary Database 192.168.10.180

Standby Database 192.168.10.13

1) Creating parameter file for the standby server.

1.1) On primary execute sql>create pfile='/tmp/init.ora' from spfile;

1.2) Edit the /tmp/init.ora for the following

*.db_unique_name='phildupstd'

*.db_file_name_convert='/<path of datafiles on old server>', ' new datafile directory on newserver'

*.log_file_name_conver='/<path of logfile on old server>', ' new logfile directory on newserver'

*.control_files='<path to control file location>'

etc

2) Start the standby server instance in no-mount mode.

Keep the same password for the both the service, using orapwd utility, or copy the password file from primary to standby server.

sql>startup nomount pfile='location to the modified pfile i.e init.ora'

3)

Configure the listeners and tnsnames.ora as following.

Listener Config on Primary

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = phildup)

(GLOBAL_DBNAME = phildup_DGMRGL )

(ORACLE_HOME = G:\app\CW.D\product\11.2.0\dbhome_1)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.180)(PORT = 1521))

)

)

tnsname.ora on primay

phildup =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.180)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = phildup)

)

)

phildupstd =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.13)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = phildup)

)

)

Listener on Standby

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = phildup)

(ORACLE_HOME = D:\app\one\product\11.2.0\dbhome_2)

)

(SID_DESC =

(SID_NAME = phildup)

(GLOBAL_DBNAME = phildupstd_DGMGRL)

(ORACLE_HOME = D:\app\one\product\11.2.0\dbhome_2)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.13)(PORT = 1521))

)

)

tnsnames.ora on standby

phildup =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.180)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = phildup)

)

)

phildupstd =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.13)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = phildup)

)

)

4) Connect using rman as following

cmd>rman target sys/phildup@phildup auxiliary sys/phildup@phildupstd

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Nov 5 15:38:56 2010

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

connected to target database: phildup (DBID=12352317)

connected to auxiliary database: phildup (not mounted)

execute command as follows

RMAN> run {

2> allocate channel primary type disk;

3> allocate auxiliary channel standby type disk;

4> duplicate target database for standby from active database

5> ;

6> }

Thats it, duplication of standby is done.

Now we will configure the dataguard setup.

On primary

sql>alter system set log_archive_dest_2='service=phildupstd';

sql>alter system set log_archive_dest_2_state=enable;

check the latest log archive on standby.

sql> select max(sequence#) from v$archived_log;

Now Broker configuration.

On primary and standy enable broker configuration

sql>alter system set dg_broker_start=true scope=both;

Modify the listener config file to include the GLOBAL_DBNAME, as seen in above listener config file.

# dgmgrl sys/oracle

DGMGRL for Linux: Version 11.2.0.1.0 - Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

Connected.

DGMGRL> create configuration dgphildup as primary database is phildup connect identifier is phildup;

Configuration "dgphildup" created with primary database "phildup"

DGMGRL> add database phildup as connect identifier is phildupstd maintained as physical;

Database "phildup" added

DGMGRL> show configuration;

Configuration - dgphildup

Protection Mode: MaxPerformance

Databases:

phildup - Primary database

phildupstd - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

DISABLED

DGMGRL> enable configuration;

Enabled

DGMGRL> enable database neo;

Enabled.

After enable the broker you could just issue following command to do the switchover.

>dgmgrl sys/phildup

DGMGRL for Linux: Version 11.2.0.1.0 - Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.

Connected.

DGMGRL> switchover to phildupstd

DGMGRL>switchover to phildup

Performing switchover NOW, please wait...

New primary database "phildup" is opening...

Operation requires shutdown of instance "phildup" on database "phildup"

Shutting down instance "phildup"...

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

Operation requires startup of instance "phildup" on database "phildup"

Starting instance "phildup"...

ORACLE instance started.

Database mounted.

Switchover succeeded, new primary is "phildupstd.

===================Another Straight Forward Command====================

RMAN>DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE

1>NOFILENAMECHECK

2>DORECOVER

3>SPFILE

4>SET DB_UNIQUE_NAME='phildupstd'

5>SET LOG_ARCHIVE_DEST_2='SERVICE=phildup LGWR SYNC REGISTER VALID_FOR=(online_logfile,primary_role)'

6>SET STANDBY_FILE_MANAGEMENT='AUTO'

7>SET CONTROL_FILES='~/path to control files locatin'

8>SET DB_FILE_NAME_CONVERT '~\new path to datafiles'

9>SET LOG_FILE_NAME_CONVERT '~\new path to logfiles'

;

DORECOVER – This commands starts recovery after restoration

NOFILENAMECHECK – RMAN does not validate the filenames during restoration.