Being an Oracle DBA we know that what is cloning? This technical definition gives you a correct idea of the cloning. RMAN has the ability to duplicate, or clone, a database from a backup or from an active database. It is possible to create a duplicate database on a remote server with the same file structure, a remote server will a different file structure or the local server with a different file structure.
Below are the steps for doing RMAN from RAC to RAC. Steps will be same from NON RAC TO RAC .
Detail | Source | Destination |
Node 1 | prodb1-host | clonedb1-host |
Node 2 | prodb2-host | clonedb2-host |
Version | 12.1.0.2 | 12.1.0.2 |
Database Name | PRODB | CLONEDB |
Instance Name 1 | PRODB1 | CLONEDB1 |
Instance Name 2 | PRODB2 | CLONEDB2 |
First we will restore the database to only one node1 and later we will convert to RAC.
All the activities need to be done target database only.
1. Create a static listener on the target host(NODE1)( From ORACLE_HOME)
LISTENER_CLONEDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = clonedb1-host)(PORT = 1527)) ) SID_LIST_LISTENER_CLONEDB = (SID_LIST = (SID_DESC = (ORACLE_HOME = /oracle/app/oracle/product/12.1.0.2/dbhome_1) (SID_NAME = CLONEDB1) ) )
lsnrctl start LISTENER_CLONEDB
2. Add tns entry of both source and target db in tnsnames.ora file(TARGET_HOST NODE 1 )
-- SOUCE DB TNS PRODB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = prodb1-host)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PRODB) ) )
- TARGET DB TNS CLONEDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = clonedb1-host)(PORT = 1527)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = CLONEDB) ) )
3. Copy the pfile from source db and update the below parameters.
SOURCE PFILE LOOKS LIKE
*.cluster_database=TRUE *.compatible='12.1.0.2.0' *.control_files='+REDOA/PRODB/CONTROLFILE/current.256.911574607','+REDOB/PRODB/CONTROLFILE/current.256.911574607','+DATA/PRODB/CONTROLFILE/current.366.926770445'#Restore Controlfile *.db_block_size=8192 *.db_domain='' *.db_files=5000 *.db_name='PRODB' *.diagnostic_dest='/oradbtrace' PRODB1.instance_number=1 PRODB2.instance_number=2 *.large_pool_size=20g *.log_archive_dest_1='LOCATION=+ARCH' *.log_archive_dest_state_1='ENABLE' *.open_cursors=4500 *.pga_aggregate_target=40G *.processes=6000 *.remote_listener='prodb-scan.stc.com.sa:1522' *.remote_login_passwordfile='exclusive' *.sga_max_size=150G *.sga_target=150G *.shared_pool_size=21474836480 PRODB2.thread=2 PRODB1.thread=1 *.undo_retention=14400 PRODB2.undo_tablespace='UNDOTBS1' PRODB1.undo_tablespace='UNDOTBS2'
Now change the db name to CLONEDB and instance names to CLONEDB1, CLONEDB2 in the pfile.
Apart from this, we need to do the few other changes. and save it as initCLONEDB1.ora in $ORACLE_HOME/dbs location.
*.log_archive_dest_1 *.db_create_file_dest *.db_create_online_log_dest_1=’+REDOA’ *.control_files=’+REDOA’,’+REDOB’,’+DATA’ *.cluster_database=FALSE
Now the target db pfile will look as below.
Now change the db name to CLONEDB and instance names to CLONEDB1, CLONEDB2 in the pfile.
Apart from this, we need to do the few other changes. and save it as initCLONEDB1.ora in $ORACLE_HOME/dbs location.
*.log_archive_dest_1 *.db_create_file_dest *.db_create_online_log_dest_1=’+REDOA’ *.control_files=’+REDOA’,’+REDOB’,’+DATA’ *.cluster_database=FALSE
Now the target db pfile will look as below.
cat initCLONEDB1.ora
*.cluster_database=FALSE *.compatible='12.1.0.2.0' *.control_files='+REDOA','+REDOB','+DATA' *.db_block_size=8192 *.db_create_file_dest='+DATA' *.db_create_online_log_dest_1='+REDOA' *.db_create_online_log_dest_2='+REDOB' *.db_domain='' *.db_files=5000 *.db_name='CLONEDB' *.diagnostic_dest='/oradbtrace' CLONEDB1.instance_number=1 CLONEDB2.instance_number=2 *.large_pool_size=20g *.log_archive_dest_1='LOCATION=+ARCH' *.log_archive_dest_state_1='ENABLE' *.open_cursors=4500 *.pga_aggregate_target=40G *.processes=6000 *.remote_listener='clonedb-scan.stc.com.sa:1522' *.remote_login_passwordfile='exclusive' *.sga_max_size=150G *.sga_target=150G *.shared_pool_size=21474836480 CLONEDB2.thread=2 CLONEDB1.thread=1 *.undo_retention=14400 CLONEDB2.undo_tablespace='UNDOTBS1' CLONEDB1.undo_tablespace='UNDOTBS2'
4. Create password file on source and target db:(password should be same)
Now create password file on source and target db with same sys password.
-- SOURCE DB ( PRODB) cd $ORACLE_HOME/dbs orapwd file=orapw$ORACLE_SID password=oracle force=y -- TARGET DB ( CLONEDB) cd $ORACLE_HOME/dbs orapwd file=orapw$ORACLE_SID password=oracle force=y
5. Now start the target database in nomount stage:
startup nomount pfile=initCLONEDB1.ora
6. Test the connectivity to target and auxiliary:[ TARGET HOST]
rman target sys/oracle#51234@PRODB auxiliary sys/oracle#51234@CLONEDB Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 21 19:52:37 2017 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: PRODB (DBID=678234706) connected to auxiliary database: CLONEDB (not mounted)
For big databases, it is recommended to create a shell script and run in background as below.
7 . Prepare the rman run script:[TARGET HOST]
cat /export/home/oracle/rman_clone.cmd run { allocate channel src1 type disk; allocate channel src2 type disk; allocate channel src3 type disk; allocate channel src4 type disk; allocate auxiliary channel aux1 type disk; allocate auxiliary channel aux2 type disk; allocate auxiliary channel aux3 type disk; allocate auxiliary channel aux4 type disk; allocate auxiliary channel aux5 type disk; allocate auxiliary channel aux6 type disk; duplicate target database to CLONEDB from active database USING BACKUPSET ; }
8. Prepare the shell script.[TARGET HOST]
cat rman_clone_CLONEDB.sh #!/bin/ksh rman target sys/oracle#51234@PRODB auxiliary sys/oracle#51234@CLONEDB msglog /export/home/oracle/rman_clone2_log cmdfile=/export/home/oracle/rman_clone.cmd
9. Now run the script with nohup mode:[TARGET DB]
nohup sh rman_clone_CLONEDB.sh &
10. Monitor the log
— FEW PART OF THE LOG
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Feb 21 17:18:48 2017 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: PRODB (DBID=678234706) connected to auxiliary database: CLONEDB (not mounted) RMAN> run 2> { 3> allocate channel src1 type disk; 4> allocate channel src2 type disk; 5> allocate channel src3 type disk; 6> allocate channel src4 type disk; 7> allocate auxiliary channel aux1 type disk; 8> allocate auxiliary channel aux2 type disk; 9> allocate auxiliary channel aux3 type disk; 10> allocate auxiliary channel aux4 type disk; 11> allocate auxiliary channel aux5 type disk; 12> allocate auxiliary channel aux6 type disk; 13> duplicate target database to CLONEDB from active database USING BACKUPSET ; 14> } 15> 16> using target database control file instead of recovery catalog allocated channel: src1 channel src1: SID=2596 device type=DISK allocated channel: src2 channel src2: SID=2847 device type=DISK allocated channel: src3 channel src3: SID=3207 device type=DISK allocated channel: src4 channel src4: SID=2539 device type=DISK allocated channel: aux1 channel aux1: SID=5923 device type=DISK allocated channel: aux2 . . . . . . . . . . input datafile copy RECID=196 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/users.352.936559475 datafile 96 switched to datafile copy input datafile copy RECID=197 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/users.353.936559477 datafile 97 switched to datafile copy input datafile copy RECID=198 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/users.354.936559491 datafile 98 switched to datafile copy input datafile copy RECID=199 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/users.355.936559587 datafile 99 switched to datafile copy input datafile copy RECID=200 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/sysaux.356.936559587 datafile 100 switched to datafile copy input datafile copy RECID=201 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/system.357.936559595 datafile 101 switched to datafile copy input datafile copy RECID=202 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/undotbs1.358.936559689 datafile 102 switched to datafile copy input datafile copy RECID=203 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/undotbs2.359.936559925 datafile 103 switched to datafile copy input datafile copy RECID=204 STAMP=936563077 file name=+DATA/CLONEDB/DATAFILE/users.360.936560101 Reenabling controlfile options for auxiliary database Executing: alter database add supplemental log data Executing: alter database add supplemental log data(PRIMARY KEY, UNIQUE) columns Executing: alter database enable block change tracking contents of Memory Script: { Alter clone database open resetlogs; } executing Memory Script database opened Cannot remove created server parameter file Finished Duplicate Db at 21-FEB-17 released channel: src1 released channel: src2 released channel: src3 released channel: src4
Complete log:
Now the database is up and available but only on one node. We need to register the database and convert it into a RAC database.
11. Make cluster parameter to true:
alter system set cluster_database=TRUE scope=spfile sid='*';
12. Create spfile in asm disk
create pfile='/export/home/oracle/test.ora' from spfile;
— Now create the spfile in ASM dis
create spfile='+DATA/CLONEDB/PARAMETERFILE/spfileCLONEDB.ora' from pfile;
Go to $ORACLE_HOME/dbs
Update initCLONEDB1.ora as below
cat initCLONEDB1.ora SPFILE='+DATA/CLONEDB/PARAMETERFILE/spfileCLONEDB.ora'
Same thing do it on node 2:(upgrade initCLONEDB2.ora)
cat initCLONEDB2.ora SPFILE='+DATA/CLONEDB/PARAMETERFILE/spfileCLONEDB.ora'
13. Register the database and modify the configuration
srvctl add database -db CLONEDB -oraclehome /oracle/app/oracle/product/12.1.0.2/dbhome_1 srvctl add instance -d CLONEDB -i CLONEDB1 -node clonedb1-host srvctl add instance -d CLONEDB -i CLONEDB2 -node clonedb1-host srvctl modify database -d CLONEDB -spfile +DATA/CLONEDB/PARAMETERFILE/spfileCLONEDB.orasrvctl config database -d CLONEDB
14. Now shutdown the database on node 1 and restart using srvctl.
shutdown immediate; srvctl start database -d CLONEDB
— Check crs status
crsctl stat res -t ora.clonedb.db 1 ONLINE ONLINE sec54-1 Open,STABLE 2 ONLINE ONLINE sec55-1 Open,STABLE
Now RAC database is ready for use.
RESTORE FAILED RMAN ACTIVE CLONE:
While restoring a big database, cloning might fail in the mid due to a network issue. In that case, no need to start from the beginning.
Follow below steps to resume the restore.It will skip the copied files,
1. Shutdown the database
2. Remove the spfile, which rman has created during the duplication
3. Start the database with nomount stage(using the original init file, which you have used , which starting the database initially)
4. Run the same exact rman duplication script.
5. Rman will detect the files which were copied during the previous cloning process and those will be skipped.It will only restore the new datafile which was not copied previously.
It will show the warning like below:
Using previous duplicated file +DATA/CLONEDB/DATAFILE/undotbs2.628.936641735 for datafile 78 with checkpoint SCN of 11712137096850. You can ignore.
NOTE :
If the database version is 11g, then use the below rman run block:(in step 7 )
run { allocate channel src1 type disk; allocate channel src2 type disk; allocate channel src3 type disk; allocate channel src4 type disk; allocate auxiliary channel aux1 type disk; allocate auxiliary channel aux2 type disk; allocate auxiliary channel aux3 type disk; allocate auxiliary channel aux4 type disk; allocate auxiliary channel aux5 type disk; allocate auxiliary channel aux6 type disk; duplicate target database to CLONEDB from active database ; }
Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us:
Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/
Joel Perez’s LinkedIn: www.linkedin.com/in/SirDBaaSJoelPerez
Anuradha’s LinkedIn: https://www.linkedin.com/in/dbaanuradhamudgal/
LinkedIn Group: Oracle Cloud DBAAS
Facebook Page: OracleHelp
Thank you for such a post.
Foued