Friday, September 21, 2018

Cloning a RAC DB on the same cluster

We are using OMF in ASM so will include the following 3 lines in the RMAN DUPLICATE TARGET command:
SET DB_FILE_NAME_CONVERT '+DG_DATA','+DG_DATA'
SET LOG_FILE_NAME_CONVERT '+DG_DATA','+DG_DATA'
SET CONTROL_FILES='+DG_DATA','+DG_DATA'

Do NOT use NOFILENAMECHECK when closing to the same server, any error in your script and RMAN might overwrite the target DBs db files!

Also need to SET CLUSTER_DATABASE='FALSE' in the RMAN DUPLICATE TARGET command because I will clone a RAC to single instance and then convert the single instance to a RAC.

Prep includes creating a pwd file and a init.ora file with 3 lines
db_name=TMTEST
db_unique_name=TMTEST
compatible=12.1.0.2.0

I added the 3rd line after getting “RMAN-06136: ORACLE error from auxiliary database: ORA-00201: control file version 12.1.0.2.0 incompatible with ORACLE version 12.0.0.0.0” on my first clone attempt

Set ORACLE_SID to the new DB (TMTEST) and startup nomount. When launching RMAN connect to the TARGET via a TNS entry

rman target sys/XX@DLIOWCC auxiliary sys/XX
RMAN> DUPLICATE TARGET DATABASE TO TMTEST FROM ACTIVE DATABASE
SPFILE
SET CONTROL_FILES='+DG_DATA','+DG_DATA';
SET DB_FILE_NAME_CONVERT '+DG_DATA','+DG_DATA'
SET LOG_FILE_NAME_CONVERT '+DG_DATA','+DG_DATA'
SET CLUSTER_DATABASE='FALSE';

10 minutes later I had a Cloned DB with ORACLE_SID=TMTEST

Some post cloning tasks in order to make it a RAC:

SQL> show parameter spfile
NAME    TYPE    VALUE
------- ------- ---------------------------------------------------
spfile  string  /u01/oracle/product/12.1.0/db_1/dbs/spfileTMTEST.ora
SQL> alter system set cluster_database=TRUE scope=spfile sid='*';
SQL> create pfile ‘initTMTESTcloned.ora’ from spfile;
vi initTMTESTcloned.ora

Found a few entries I had to change from:
DLIOWCC2.instance_number=2
DLIOWCC1.instance_number=1
DLIOWCC2.thread=2
DLIOWCC1.thread=1
DLIOWCC1.undo_tablespace='UNDOTBS1'
DLIOWCC2.undo_tablespace='UNDOTBS2'
To
TMTEST2.instance_number=2
TMTEST1.instance_number=1
TMTEST2.thread=2
TMTEST1.thread=1
TMTEST1.undo_tablespace='UNDOTBS1'
TMTEST2.undo_tablespace='UNDOTBS2'

SQL> create spfile='+DG_DATA/TMTEST/spfileTMTEST.ora' from pfile='initTMTESTcloned.ora';
vi initTMTEST1.ora
add line spfile='+DG_DATA/TMTEST/spfileTMTEST.ora'
copy the init.ora and orapw file to node 2

Register the database and modify the configuration
srvctl add database -db TMTEST -oraclehome /u01/app/oracle/product/12.1.0/dbhome_1 -spfile +DG_DATA/TMTEST/spfileTMTEST.ora
srvctl add instance -db TMTEST -i TMTEST1 -node node1za
srvctl add instance -db TMTEST -i TMTEST2 -node node2za
srvctl config database -db TMTEST

shutdown the instance (remember ORACLE_SID=TMTEST)
and start the DB from srvctl
srvctl start database -db TMTEST

Remember to change ORACLE_SID from TMTEST to TMTEST1 if you want to connect via sqlplus on the DB node node1za

No comments: