Duplicate RAC Database Without Connecting To Target Database

Duplicate test RAC database from prod RAC database using overnight tape RMAN backups.

This post demonstrates how to refresh RAC TEST database from source RAC PROD database without connecting to source RAC PROD database by using overnight tape backups.

Subscribe to get access

Read more of this content when you subscribe today.

Create Standby Database From RMAN Backup

Create a RAC Standby Database from Overnight RMAN Tape Backups with 20 steps.

This post demonstrates how to build a RAC standby database by using overnight  RMAN ( Netbackup ) backups in 11.2.

Subscribe to get access

Read more of this content when you subscribe today.

How to Relocate Standby Database ASM Datafiles

The alternative for relocating ASM datafiles by RMAN commands :
CATALOG START WITH “+DATA2/../”
SWITCH DATABASE TO COPY.

TASK

This task is to relocate all the datafiles of diskgroup DATA1 to another diskgroup DATA2 for a standby database.

SOULUTION

1)Check the diskgroup space availability.

SQL> set pagesize 120
SQL> set linesize 180
SQL> select NAME,TOTAL_MB/1024,FREE_MB/1024,USABLE_FILE_MB/1024 
       from v$asm_diskgroup;

NAME T    TOTAL_MB/1024 FREE_MB/1024 USABLE_FILE_MB/1024
--------- ------------- ------------ -------------------
DATA1     1024.00977      15.6894531   15.6894531
OCR_VOTE    19.9931641    15.4257813   15.4257813
FRA        500.069336    210.331055   210.331055
DATA2     4000.55469    1816.02344   1816.02344

2)Leave managed standby database recovery still going. Create a RMAN script by using below query:

SQL> select 'backup as copy datafile '||file#||' format ''+DATA2'';' 
       from v$datafile 
      where name like '+DATA1%' order by 1;

'BACKUPASCOPYDATAFILE'||FILE#||'FORMAT''+DATA2'';'
---------------------------------------------------
backup as copy datafile 124 format '+DATA2';
backup as copy datafile 125 format '+DATA2';
backup as copy datafile 126 format '+DATA2';
backup as copy datafile 127 format '+DATA2';
.....
....
...
..
.

The final RMAN script content:

$cat move_DATA1_to_DATA2.rman

run {
allocate channel stdbych1 type disk;
allocate channel stdbych2 type disk;
allocate channel stdbych3 type disk;
allocate channel stdbych4 type disk;
backup as copy datafile 124 format '+DATA2';
backup as copy datafile 125 format '+DATA2';
backup as copy datafile 126 format '+DATA2';
backup as copy datafile 127 format '+DATA2';
....
...
..
.
}

3) Run the RMAN script to make a copy of all datafiles on diskgroup DATA1 onto diskgroup DATA2.

$nohup rman target / cmdfile=/u01/app/oracle/admin/scripts/move_DATA1_to_DATA2.rman  log=/u01/app/oracle/admin/scripts/move_DATA1_To_DATA2.log &

4) Stop the managed standby database recovery.

SQL> alter database recover managed standby database cancel;

Database altered.

5) Switch the datafiles.

RMAN>switch datafile 124 to copy;
RMAN>switch datafile 125 to copy;
RMAN>switch datafile 126 to copy;
RMAN>switch datafile 127 to copy;
....
...
..
.

6) Start the recovery.

SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

5) Archive log switch, check applied from alert.log, etc.

SQL>alter system archive log current ;
System altered.

6) Unmount diskgroup DATA1 on all the nodes, except the current node.

SQL> alter diskgroup data1 dismount;
Diskgroup altered.

7) Drop the diskgroup DATA1.

SQL> drop diskgroup data1;
drop diskgroup data1
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15053: diskgroup "DATA1" contains existing files

SQL> drop diskgroup data1 including contents;
Diskgroup dropped.

8) Scan disks and confirm the ASM Disks of DATA1 have been removed from ASM disks.

$su - 

# oracleasm listdisks
ASM_DISK01
ASM_DISK02
ASM_DISK03
ASM_DISK04
ASM_DISK05
ASM_DISK06
ASM_DISK07
ASM_DISK08
ASM_FRA01
ASM_SSD1  <----- DATA1 diskgroup
OCR_VOTE01

# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Cleaning disk "ASM_SSD1"
Scanning system for ASM disks...

# oracleasm listdisks
ASM_DISK01
ASM_DISK02
ASM_DISK03
ASM_DISK04
ASM_DISK05
ASM_DISK06
ASM_DISK07
ASM_DISK08
ASM_FRA01
OCR_VOTE01

Add Extra ASM Control File

Use RMAN command “restore controlfile from” to duplicate a controlfile.

Playing around to add another control file into ‘+DATA2’ disk group.

Check current control files

SQL> select name from v$controlfile;

NAME
----------------------------------------------------------
+DATA2/ractest/controlfile/current.523.925063153
+FRA/ractest/controlfile/current.1395.925063153

SQL> show parameter control_file

NAME                                TYPE VALUE
------------------------------------ ----------- -------------------------
control_file_record_keep_time integer 7
control_files                 string   +DATA2/ractest/controlfile/current.523.925063153, +FRA/ractest/controlfile/current.1395.925063153

Change “control_file” parameter in spfile only.

SQL> alter system set control_files='+DATA2','+DATA2/ractest/controlfile/current.523.925063153','+FRA/ractest/controlfile/current.1395.925063153' scope=spfile;

System altered.

Shut down and startup in nomount mode.

SQL> shutdown immediate;
Database dismounted.
ORACLE instance shut down.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 8551575552 bytes
Fixed Size 2270360 bytes
Variable Size 1543506792 bytes
Database Buffers 6996099072 bytes
Redo Buffers 9699328 bytes

Copy another control file to ‘+DATA2’  by restoring from any current available control file.

RMAN> restore controlfile from '+DATA2/ractest/controlfile/current.523.925063153';

Starting restore at 13-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=58 instance=ractest1 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+DATA2/ractest/controlfile/current.555.925125605 <-- New one
output file name=+DATA2/ractest/controlfile/current.523.925063153 <-- Old one
output file name=+FRA/ractest/controlfile/current.1395.925063153  <-- Old one
Finished restore at 13-OCT-16

RMAN> exit

Recovery Manager complete.

Check the parameter ‘control_file’ was updated automatically.

SQL> show parameter control_file

NAME                           TYPE    VALUE
------------------------------ ------- ----------------------
control_file_record_keep_time  integer 7
control_files                  string  +DATA2/ractest/controlfile/current.555.925125605,
+DATA2/ractest/controlfile/current.523.925063153, +FRA/ractest/controlfile/current.1395.925063153


SQL> alter database open;

Database altered.

SQL> show parameter control_file

NAME                          TYPE    VALUE
----------------------------- ------- ------------------------------
control_file_record_keep_time integer 7
control_files                 string +DATA2/ractest/controlfile/current.555.925125605,
+DATA2/ractest/controlfile/current.523.925063153, +FRA/ractest/controlfile/current.1395.925063153

What Is the File “_rm_dup_$ORACLE_SID.dat” Under ORACLE_HOME/dbs of Auxiliary Host

“_rm_dup_.dat” file is for “restore optimization” purpose to record which datafiles have been restored/copied onto auxiliary host, when running RMAN “duplicate target database for standby from active database”.

There is a file with name  “_rm_dup_$ORACLE_SID.dat” under $ORACLE_HOME/dbs of the clone database.  This file is from executing “duplicate database ….”

“_rm_dup_<dup_db>.dat” stores the names of datafilecopy already created by duplicate. Inside this file,  rman can find the name of the datafiles already copied to auxiliary host. if, for some reasons, the duplicate failed, the second duplicate will check this file. If the datafilecopy has been created on auxilary host, and the vital information of the datafile (file number, database id, creation scn, database name) and its checkpoint scn is behind the until scn, then the datafilecopy can be used by this new duplicate and restore/copy is not necessary.

So this file helps for “restore optimization” purpose when running RMAN “duplicate database …..”.