Monday, 28 December 2015
Duplicate a RAC database without connecting to it but using only its backups.
Title :
Duplicate a RAC database without connecting to it but using only its backups.
Comment:
It's never to late to learn new stuff, let's get started, shall we ?
Following you'll find a complete procedure to duplicate a RAC database using only a RMAN backupset and what's more how to add its instances to a RAC cluster already created. Each stuff will be done manually.
Be careful :
1) Duplicate process could overwrite online log files of the source database.
2) If present disable encryption before duplicate on the source database.
3) if present disable block tracking option on the source database.
Procedure steps :
1) Take a backup of the spfile, controlfile, database, and archivelogs as follows:
export ORACLE_SID=ISTANCE1
RMAN> connect target /
connected to target database: ISTANCE1 (DBID=9999999)
RMAN> backup spfile;
Starting backup at 02-DEC-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 instance=ISTANCE1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 02-DEC-15
channel ORA_DISK_1: finished piece 1 at 02-DEC-15
piece handle=/orafra/ISTANCE1/backupset/2015_12_02/o1_mf_nnsnf_TAG20151202T100902_c5xf9h96_.bkp tag=TAG20151202T100902 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-DEC-15
Starting Control File and SPFILE Autobackup at 02-DEC-15
piece handle=/orafra/ISTANCE1/autobackup/2015_12_02/o1_mf_s_897386944_c5xf9kt7_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 02-DEC-15
RMAN> backup database include current controlfile plus archivelog ;
2) Create a password file for the auxiliary instance:
Copy the password file from the target database to $ORACLE_HOME/dbs and rename it.
cd $ORACLE_HOME/dbs
cp orapwINSTANCE1 orapwCLONE1
3) Drop any previous created clone database:
export ORACLE_SID=CLONE1
tail -f /u01/app/oracle/diag/rdbms/CLONE1/CLONE1/trace/alert_CLONE1.log
sqlplus / as sysdba
SQL> shutdown immediate;
SQL> startup pfile='/home/oracle/dbascript/pfileCLONE1.ora' mount restrict;
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
CLONE1
SQL> drop database;
4) Verify that all files have been removed from ASM diskgroup:
ASMCMD> cd DG_DBF/
ASMCMD> ls -l
Type Redund Striped Time Sys Name
Y CLONE/
Then create the directory for the CLONE database:
ASMCMD> mkdir clone
ASMCMD> cd clone
Below I'll explain why that directory is required.
ASMCMD> mkdir instance1
5) Create a initialization parameter for the auxiliary instance with the following parameters:
vi /home/oracle/dbascript/pfileCLONE.ora
DB_NAME=CLONE
db_unique_name=CLONE
control_files='+DG_DBF/clone/control1.ctl'
db_file_name_convert='+DG_DBF','+DG_DBF/clone'
log_file_name_convert='+DG_LOG1','+DG_DBF/clone'
The first value of the parameter db_file_name_convert and log_file_name_convert comes up from the following queries:
select name from v$datafile;
select member from v$logfile;
6) Due to the following Bug 11063122 RMAN "DUPLICATE" RESTORES AN AUXILIARY CONTROLFILE WITH PRIMARY REDOLOGS, it's better to shutdown the source database:
export ORACLE_SID=INSTANCE1
[oracle@test ]$ srvctl stop instance -d INSTANCE -i INSTANCE1
[oracle@test ]$ srvctl stop instance -d INSTANCE -i INSTANCE2
6) Duplicate the database executing the following commands:
export ORACLE_SID=CLONE1
sqlplus / as sysdba
SQL> startup nomount pfile='/home/oracle/dbascript/pfileclone.ora';
SQL> create spfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileclone.ora' from pfile='/home/oracle/dbascript/pfileclone.ora';
shutdown immediate;
SQL> startup nomount
Startup Log :
System parameters with non-default values:
control_files = "+DG_DBF/clone/control1.ctl"
db_file_name_convert = "+DG_DBF"
db_file_name_convert = "+DG_DBF/clone"
log_file_name_convert = "+DG_LOG1"
log_file_name_convert = "+DG_DBF/clone"
db_name = "CLONE"
db_unique_name = "CLONE"
Execute RMAN command and connect as auxiliary
rman auxiliary /
duplicate database to clone backup location '/orafra/INSTANCE';
It's required to specify the directory location of the source DB backup ('/orafra/INSTANCE')
WARNING : OK
RMAN-05529: WARNING: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.
Log restore controlfile: OK
Starting restore at 02-DEC-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=149 device type=DISK
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=+DG_DBF/clone/control1.ctl
Finished restore at 02-DEC-15
Log restore datafiles : OK
Full restore complete of datafile 31 to datafile copy +DG_DBF/clone/datafile/tbs1381.897390253. Elapsed time: 0:04:13
Full restore complete of datafile 100 to datafile copy +DG_DBF/clone/datafile/tbs2.378.897390263. Elapsed time: 0:05:55
ecc...
Log files restore: OK
Online log +DG_DBF/clone/onlinelog/group_4.417.897403979: Thread 2 Group 4 was previously cleared
Online log +DG_DBF/clone/onlinelog/group_5.465.897403985: Thread 2 Group 5 was previously cleared
Online log +DG_DBF/clone/onlinelog/group_6.400.897403989: Thread 2 Group 6 was previously cleared
Online log +DG_DBF/clone/onlinelog/group_7.408.897404005: Thread 1 Group 7 was previously cleared
Online log +DG_DBF/clone/onlinelog/group_8.451.897404011: Thread 1 Group 8 was previously cleared
Online log +DG_DBF/clone/onlinelog/group_9.392.897404017: Thread 1 Group 9 was previously cleared
Temp file : OK
Re-creating tempfile +DG_DBF as +DG_DBF/clone/tempfile/temp_rac.488.897392673
Finished Duplicate Db at 02-DEC-15
7) Restart the source Instances:
[oracle@test ]$ srvctl start instance -d INSTANCE -i INSTANCE1
[oracle@test ]$ srvctl start instance -d INSTANCE -i INSTANCE2
8) Start the cloned instance: CLONE1:
SQL> startup nomount pfile='/home/oracle/dbascript/pfileCLONE1.ora';
ORACLE instance started.
8) Verify the cloned instance:
Logfiles : MEMBER
--------------------------------------------------------------------------------
+DG_DBF/clone/onlinelog/group_9.487.897392667
+DG__DBF/clone/onlinelog/group_8.486.897392663
+DG_DBF/clone/onlinelog/group_7.485.897392655
+DG_DBF/clone/onlinelog/group_4.482.897392633
+DG_DBF/clone/onlinelog/group_5.483.897392637
+DG_DBF/clone/onlinelog/group_6.484.897392641
Datafiles : NAME
--------------------------------------------------------------------------------
+DG_DBF/clone/datafile/system.414.897402601
+DG_DBF/clone/datafile/tbs1381.897390253
+DG_DBF/clone/datafile/tbs2.378.897390263
ControlFile : NAME
------- -----------------------------------------------------------------------
+DG_DBF/clone/control1.ctl
Tempfile: NAME
--------------------------------------------------------------------------------
+DG_DBF/clone/tempfile/temp_rac.488.897392673
That's all, the instance has been cloned and it's online.
The last step is to add it to the RAC...
Byeeee....
References :
RMAN 11GR2 : DUPLICATE Without Target And Recovery Catalog Connection (Doc ID 874352.1)
How to avoid a failed duplicate to overwrite the online redologs of the target Database? (Doc ID 1282984.1).
This has been taken care of in 11.2.0.2 onwards as discussed in Bug 11063122 RMAN "DUPLICATE" RESTORES AN AUXILIARY CONTROLFILE WITH PRIMARY REDOLOGS
Subscribe to:
Comments (Atom)