The Following Assumptions Are Made in This Document

Introduction

Purpose

This document outlines the procedure to clone an Oracle 10g RAC database using the Oracle RMAN DUPLICATE DATABASE feature.

Scope

Although the document is specific to illustrating the clone procedure using the example of SOURCEC3 as the source database and TARGETC3 as the target database, the same procedure can be used for performing a clone of any of the RAC databases.

Assumptions and Prerequisites

The following assumptions are made in this document.

q  A valid RMAN backup of the source database and archive log files exists. This includes the backup of the controlfile as well.

q  The same directory structure exists on target server as compared to source server where the RMAN backupsets are located.

q  Source and target database have the same SYS password

Note:

If the source and target database SYS passwords are different, we need to do either

a)  Make a copy of the target database existing password file and copy the password file from the $ORACLE_HOME/dbs location on source database server to same location on the target database server.

b)  Make a copy of the target database existing password file and recreate using the orapwd command, but using the SYS password of the source database

Reference Documents

Metalink Note 461479.1
Oracle DBA and RAC DBA Expert / RMAN Duplicate Database From RAC ASM To RAC ASM
http://www.oracleracexpert.com/2009/12/duplicate-rac-database-using-rman.html

Prepare the source and target databases for the clone process

Prepare the source database to enable auxiliary connection to the target database

Update tnsnames.ora on the source database server

Create a TNS Alias for the auxiliary connection on the source database $ORACLE_HOME/network/admin/tnsnames.ora

TARGETC3 =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = node1-vip.mydomain)(PORT = 2098))

)

(CONNECT_DATA =

(SERVICE_NAME = TARGETC3.mydomain)

)

)

Prepare the target database to allow auxiliary connection from the source database

Add a static entry in the listener.ora of the target database server

The GLOBAL_DBNAME entry will be used to reference the static service_name in the listener.

Add a static entry for the auxiliary connection in the target database $ORACLE_HOME/network/admin/listener.ora

(SID_DESC =

(GLOBAL_DBNAME =TARGETC3.mydomain)

(ORACLE_HOME =/node2/oracle/targetc3 )

(SID_NAME = TARGETC31)

)

Reload the listener

$> lsnrctl reload LISTENER_TARGETC3_NODE1

LSNRCTL for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Production on 27-MAR-2012 13:14:23

Copyright (c) 1991, 2007, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip.mydomain)(PORT=2098)(IP=FIRST)))

The command completed successfully

Identify the Archive Log Sequence until which Recovery will be performed

We need to identify the archive log sequence number which we will use in the DUPLICATE DATABASE command. RMAN will perform recovery of the database until the log sequence number that we need to determine.

Run the RMAN command LIST BACKUP OF ARCHIVELOG.

Note the last or latest archive log backup for each thread.

Then among the two archive log sequence numbers, identify the one which has the lower NEXT_SCN number.

That will be the archive log sequence that we need to make a note of.

Remember, we need to add 1 to this number which is then used in the SET UNTIL SEQUENCE clause of the DUPLICATE DATABASE command.

For example, we see that for thread 1, the most recent archive log backup available belongs to log sequence number 63643 while for thread 2 the most recent archive log backup available belongs to log sequence number 62635.

Comparing, the NEXT_SCN value for both those sequence numbers, we can see that for sequence 63643, the NEXT_SCN value is lower (7367465329753 compared with 7367465329755).

Thrd Seq Low SCN Low Time Next SCN Next Time

1 63640 7367465305170 28-MAR-12 7367465313001 28-MAR-12

1 63641 7367465313001 28-MAR-12 7367465318557 28-MAR-12

1 63642 7367465318557 28-MAR-12 7367465325967 28-MAR-12

1 63643 7367465325967 28-MAR-12 7367465329753 28-MAR-12

2 62632 7367465305151 28-MAR-12 7367465312995 28-MAR-12

2 62633 7367465312995 28-MAR-12 7367465318549 28-MAR-12

2 62634 7367465318549 28-MAR-12 7367465325955 28-MAR-12

2 62635 7367465325955 28-MAR-12 7367465329755 28-MAR-12

So in the RMAN DUPLICATE DATABASE command , we will use :

SET UNTIL SEQUENCE 63644 THREAD 1

Create the Single-Instance init.ora parameter file

The database is first restored as a single-instance database and then we convert the single-instance database to a cluster database. It should be noted that we cannot perform a direct RAC database to RAC database duplicate operation, but we can clone a RAC database to a single-instance database.

Backup the existing init.ora parameter file

$ mv initTARGETC31.ora initTARGETC31.ora.orig

Create a new init.ora file based on the spfile

We will later remove all the RAC related parameters from the init.ora file which we will use to bring up a single-instance database.

SQL> create pfile from spfile;

File created.

q  Stop Collaboration Suite

At this stage, we will first stop Oracle Collaboration Suite processes using the standard operating procedures. The opmnctl command can be used for this purpose.

q  Shutdown the target database

After it has been confirmed that the Collaboration Suite Middle Tier processes have been stopped, we need to then proceed with the shutdown of the C3 Oracle database on the target server

$> srvctl stop database -d TARGETC3

$> srvctl status database -d TARGETC3

Instance TARGETC31 is not running on node node1

Instance TARGETC32 is not running on node node2

q  Prepare the (single-instance) target database init.ora file

We now have to remove all the RAC related entries from the parameter file.

We also removed the local_listener parameter from the init.ora file as we had received an error when the instance started related to the local_listener parameter.

Remove the following entries

*.cluster_database=TRUE

TARGETC31.instance_number=1

TARGETC32.instance_number=2

TARGETC31.local_listener='LISTENER_TARGETC31'

TARGETC32.local_listener='LISTENER_TARGETC32'

TARGETC31.thread=1

TARGETC32.thread=2

TARGETC31.undo_tablespace='UNDOTBS1'

TARGETC32.undo_tablespace='UNDOTBS2'

*.local_listener='LISTENER_TARGETC3'

Add the following entries

*.db_file_name_convert='/node1/oradata/SOURCEC3/','/shared_disk/oradata/TARGETC3/'

*.log_file_name_convert='/node1/oradata/SOURCEC3/','/shared_disk/oradata/TARGETC3/'

*.undo_tablespace='UNDOTBS1’

_no_recovery_through_resetlogs=TRUE

Note:

The hidden parameter ‘_no_recovery_through_resetlogs’ has been set in order to avoid 'Internal Bug 4355382 ORA-38856: FAILED TO OPEN DATABASE WITH RESETLOGS WHEN USING RAC BACKUP.

Clean up the target database

On target database server, remove all the database files from the appropriate location.

Important: Verify that the directory location from where the files are being deleted is the right one.

$> pwd

/shared_disk/oradata/TARGETC3

$> hostname

node1.mydomain

$> rm *.dbf

$> rm *.ctl

$> rm *.log

On source database server, check that the required RMAN backups exist and are current

Execute the following RMAN commands to determine the name and location of the backupsets from the most recent database backup.

RMAN> LIST BACKUP OF DATABASE;

RMAN> LIST BACKUP OF ARCHIVELOG ALL

RMAN> LIST BACKUP OF CONTROLFILE;

Once the backupsets have been identified, confirm at the O/S level that all the backups are physically present in the appropriate location.

$> ls -l /node1/backup/SOURCEC3/backupsets/

total 1324576

-rw-r----- 1 ornode2 dba 38899712 Mar 27 14:12 SOURCEC3_ArchLog_t778994668_s7054_p1

-rw-r----- 1 ornode2 dba 43043840 Mar 27 14:12 SOURCEC3_ArchLog_t778994668_s7055_p1

-rw-r----- 1 ornode2 dba 2688512 Mar 27 14:12 SOURCEC3_ArchLog_t778994699_s7056_p1

-rw-r----- 1 ornode2 dba 427638784 Mar 27 14:12 SOURCEC3_DataFile_t778994414_s7052_p1

-rw-r----- 1 ornode2 dba 165797888 Mar 27 14:12 SOURCEC3_DataFile_t778994416_s7053_p1

$> ls -l /node1/backup/SOURCEC3/controlfiles

total 90520

-rw-r----- 1 ornode2 dba 46333952 Mar 27 14:14 c-2044054386-20120327-00

Perform the database clone using the RMAN DUPLICATE database command

q  Startup the target instance in NOMOUNT mode

Startup the target database instance in nomount state. Note that we are starting up the database initially in single-instance mode and this command needs to be executed only on one of the nodes in the RAC cluster.

SQL> STARTUP NOMOUNT pfile=’initTARGETC3.ora’;

q  On Source database server, run the script which will execute the RMAN DUPLICATE command.

We create an Unix shell script duplicatedb.sh which will establish the auxiliary database connection and execute the RMAN commands required to duplicate the database.

These are the contents of the Unix shell script duplicatedb.sh

rman target / auxiliary sys/syspwd@targetc3 <EOF

run

{

allocate channel c1 type disk;

allocate auxiliary channel c2 type disk format '/node1/backup/SOURCEC3/backupsets/%U';

set until sequence 63644 thread 1;

duplicate target database to targetc3;

}

EOF

syspwd: This is the SYS password in the target database. As mentioned earlier, the SYS password in both the source as well as target database needs to be the same.

targetc3: This is the tnsnames.ora alias which we had created earlier to connect to the auxiliary instance.

63634: This is the log sequence number we had derived earlier by examining the backup of the archive log files.

q  Execute the script to perform the duplicate

./duplicatedb.sh > duplicatedb.log

q  Monitor the progress of the RMAN restore and recover operation

From another session we can monitor the progress of the DUPLICATE database operation by executing the command:

tail -f duplicatedb.log

The output of the duplicatedb.log can be viewed in the APPENDIX (A) section of this document.

Convert the database to a RAC database

Create additional online redo log thread

q  Identify the number of size of online redo log files belonging to thread 1

Identify the current online redo log files and their size. We need to create another thread of redo log files with the same size and number as currently exist.

SQL> select group#,thread#,bytes/1048576 from v$log;

GROUP# THREAD# BYTES/1048576

------

1 1 10

2 1 10

3 1 10

SQL> select member from v$logfile;

MEMBER

------

/shared_disk/oradata/TARGETC3/redo03.log

/shared_disk/oradata/TARGETC3/redo02.log

/shared_disk/oradata/TARGETC3/redo01.log

q  Add additional online redo logs to thread 2 and enable the thread as public

SQL> alter database add logfile thread 2 group 4

2 '/shared_disk/oradata/TARGETC3/redo04.log' size 10m;

Database altered.

SQL> alter database add logfile thread 2 group 5

2 '/shared_disk/oradata/TARGETC3/redo05.log' size 10m;

Database altered.

SQL> alter database add logfile thread 2 group 6

2 '/shared_disk/oradata/TARGETC3/redo06.log' size 10m;

Database altered.

SQL> select group#,thread#,bytes/1048576 from v$log;

GROUP# THREAD# BYTES/1048576

------

1 1 10

2 1 10

3 1 10

4 2 10

5 2 10

6 2 10

6 rows selected.

SQL> alter database enable public thread 2;

Database altered.

Shutdown the database and restart it with the original parameter file.

We now shutdown the single-instance database and start it up using the original database parameter file. The database is now RAC enabled.

SQL> shutdown immediate;

Note that now the init.ora parameter file points to the SPFILE which is located on the shared disks and which contains all the RAC related database parameters.

$> mv initTARGETC31.ora initTARGETC31.ora.nonRAC

$> mv initTARGETC31.ora.orig initTARGETC31.ora

$> cat initTARGETC31.ora

spfile=/sharedvol/admin/TARGETC3/spfileTARGETC3.ora

$> srvctl start database -d TARGETC3

Perform post-clone tasks

Verify the database has been converted to a RAC enabled database

Now start the RAC database using srvctl and confirm that the CLUSTER_DATABASE parameter is TRUE and that both the instances are running on the appropriate nodes of the cluster.

$> srvctl status database -d TARGETC3

Instance TARGETC31 is running on node node1

Instance TARGETC32 is running on node node2

SQL> show parameter cluster_database

NAME TYPE VALUE

------

cluster_database boolean TRUE

cluster_database_instances integer 2

Start Collaboration Suite using standard operating procedures

After the C3 database has been restarted, we need to start the Collaboration Suite middle-tier and the listener using standard operating procedures.

APPENDIX A

duplicatedb.log output

Recovery Manager: Release 10.2.0.4.0 - Production on Wed Mar 28 13:09:20 2012

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: SOURCEC3 (DBID=2044054386)

connected to auxiliary database: TARGETC3 (not mounted)

RMAN> 2> 3> 4> 5> 6> 7>

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: sid=289 instance=SOURCEC31 devtype=DISK

allocated channel: c2

channel c2: sid=537 devtype=DISK

executing command: SET until clause

Starting Duplicate Db at 28-MAR-12

contents of Memory Script:

{

set until scn 7367465329753;

set newname for datafile 1 to

"/shared_disk/oradata/TARGETC3/system01.dbf";

set newname for datafile 2 to

"/shared_disk/oradata/TARGETC3/undotbs1.dbf";

set newname for datafile 3 to

"/shared_disk/oradata/TARGETC3/sysaux01.dbf";

set newname for datafile 4 to

"/shared_disk/oradata/TARGETC3/users01.dbf";

set newname for datafile 5 to

"/shared_disk/oradata/TARGETC3/portal.dbf";

set newname for datafile 6 to

"/shared_disk/oradata/TARGETC3/ptldoc.dbf";

set newname for datafile 7 to

"/shared_disk/oradata/TARGETC3/ptlidx.dbf";

set newname for datafile 8 to

"/shared_disk/oradata/TARGETC3/ptllog.dbf";

set newname for datafile 9 to

"/shared_disk/oradata/TARGETC3/ias_meta01.dbf";

set newname for datafile 10 to

"/shared_disk/oradata/TARGETC3/discopltm1.dbf";

set newname for datafile 11 to

"/shared_disk/oradata/TARGETC3/discopltc1.dbf";

set newname for datafile 12 to

"/shared_disk/oradata/TARGETC3/dcm.dbf";

set newname for datafile 13 to

"/shared_disk/oradata/TARGETC3/oss_sys01.dbf";

set newname for datafile 14 to

"/shared_disk/oradata/TARGETC3/wcrsys01.dbf";

set newname for datafile 15 to

"/shared_disk/oradata/TARGETC3/b2b_rt.dbf";

set newname for datafile 16 to

"/shared_disk/oradata/TARGETC3/b2b_dt.dbf";

set newname for datafile 17 to

"/shared_disk/oradata/TARGETC3/b2b_idx.dbf";

set newname for datafile 18 to

"/shared_disk/oradata/TARGETC3/b2b_lob.dbf";

set newname for datafile 19 to

"/shared_disk/oradata/TARGETC3/orabpel.dbf";

set newname for datafile 20 to

"/shared_disk/oradata/TARGETC3/bam.dbf";

set newname for datafile 21 to

"/shared_disk/oradata/TARGETC3/oca.dbf";

set newname for datafile 22 to

"/shared_disk/oradata/TARGETC3/uddisys01.dbf";

set newname for datafile 23 to

"/shared_disk/oradata/TARGETC3/attrs1_oid.dbf";

set newname for datafile 24 to

"/shared_disk/oradata/TARGETC3/battrs1_oid.dbf";

set newname for datafile 25 to

"/shared_disk/oradata/TARGETC3/gcats1_oid.dbf";

set newname for datafile 26 to

"/shared_disk/oradata/TARGETC3/gdefault1_oid.dbf";

set newname for datafile 27 to

"/shared_disk/oradata/TARGETC3/svrmg1_oid.dbf";

set newname for datafile 28 to

"/shared_disk/oradata/TARGETC3/RTC_LOOKUP_DATA.dbf";

set newname for datafile 29 to

"/shared_disk/oradata/TARGETC3/RTC_LOOKUP_INDEX.dbf";

set newname for datafile 30 to

"/shared_disk/oradata/TARGETC3/RTC_TRANSACTION_DATA.dbf";

set newname for datafile 31 to

"/shared_disk/oradata/TARGETC3/RTC_TRANSACTION_INDEX.dbf";

set newname for datafile 32 to

"/shared_disk/oradata/TARGETC3/RTC_ARCHIVE_DATA.dbf";

set newname for datafile 33 to

"/shared_disk/oradata/TARGETC3/RTC_ARCHIVE_INDEX.dbf";

set newname for datafile 34 to

"/shared_disk/oradata/TARGETC3/RTC_DOCUMENT_DATA.dbf";

set newname for datafile 35 to

"/shared_disk/oradata/TARGETC3/RTC_DOCUMENT_INDEX.dbf";

set newname for datafile 36 to

"/shared_disk/oradata/TARGETC3/RTC_RECORDING_DATA.dbf";

set newname for datafile 37 to

"/shared_disk/oradata/TARGETC3/RTC_RECORDING_INDEX.dbf";

set newname for datafile 38 to

"/shared_disk/oradata/TARGETC3/RTC_TRANSIENT_DATA.dbf";

set newname for datafile 39 to

"/shared_disk/oradata/TARGETC3/RTC_TRANSIENT_INDEX.dbf";

set newname for datafile 40 to

"/shared_disk/oradata/TARGETC3/RTC_TRANSIENT_LOB_DATA.dbf";

set newname for datafile 41 to

"/shared_disk/oradata/TARGETC3/RTC_TRANSIENT_LOB_INDEX.dbf";

set newname for datafile 42 to

"/shared_disk/oradata/TARGETC3/RTC_REPORT_DATA.dbf";

set newname for datafile 43 to

"/shared_disk/oradata/TARGETC3/RTC_REPORT_INDEX.dbf";

set newname for datafile 44 to

"/shared_disk/oradata/TARGETC3/RTC_IM_DATA.dbf";

set newname for datafile 45 to

"/shared_disk/oradata/TARGETC3/RTC_IM_INDEX.dbf";

set newname for datafile 46 to

"/shared_disk/oradata/TARGETC3/cwsys_main_tbs.dbf";

set newname for datafile 47 to