You are on page 1of 13

GSD DBA – Database Clone

CLONING USING RMAN BACKUP


CITY OF ATLANTA
Author:
Creation Date:
Last Updated: June 13,2011
Update by : Prasanth OV
Control Number: 1.
Version:

Approvals:

<Approver 1>

<Approver 2>
Document Control

Change Record

Date Author Versi Change Reference


on

Reviewers

Name Position

Distribution

Copy Name Location


No.

1
2
3
4
Document Control 2

PREPARATION 4
PREPARATION 

# Step Detail Reference

1 Get the list of datafile 1.Login to PROD and get the list of datafiles from v$datafile as
from the instance which follows:
is used as a PROD for set head off
cloning set pages 0
select 'set newname for datafile '||file#||' to ' ||''''||name||''''||';'
from v$datafile;
select 'set newname for tempfile '||FILE#||' to ' ||''''||name||''''||';'
from v$tempfile;

2.Spool the above to a files

2a Edit the spooled file 1.Edit the spool file with the target datafile location paths.
2b Use the attached script 1.Once edited append other lines in the file (clone_target.rman)
as reference taking attached script as reference
tcrp5i_rman.cmd
run {
allocate AUXILIARY CHANNEL c1 type disk;
allocate AUXILIARY CHANNEL c2 type disk;
allocate AUXILIARY CHANNEL c3 type disk;
allocate AUXILIARY CHANNEL c4 type disk;
set newname for datafile 1 to '/tcrp5i/oradata/data02/system01.dbf';
set newname for datafile 2 to '/tcrp5i/oradata/data02/system02.dbf';
set newname for datafile 3 to '/tcrp5i/oradata/data02/system03.dbf';
set newname for datafile 4 to '/tcrp5i/oradata/data02/system04.dbf';
set newname for datafile 5 to '/tcrp5i/oradata/data02/system05.dbf';
set newname for datafile 6 to '/tcrp5i/oradata/data02/system06.dbf';
set newname for datafile 7 to '/tcrp5i/oradata/data02/system07.dbf';
set newname for datafile 8 to '/tcrp5i/oradata/data02/system08.dbf';
set newname for datafile 9 to '/tcrp5i/oradata/data02/system09.dbf';
set newname for datafile 10 to '/tcrp5i/oradata/data02/system10.dbf';
set newname for datafile 11 to '/tcrp5i/oradata/data02/system11.dbf';
set newname for datafile 12 to '/tcrp5i/oradata/data01/undo01.dbf';
set newname for datafile 13 to '/tcrp5i/oradata/data01/a_archive01.dbf';
set newname for datafile 14 to '/tcrp5i/oradata/data01/a_int01.dbf';
set newname for datafile 15 to '/tcrp5i/oradata/data01/a_media01.dbf';
set newname for datafile 16 to '/tcrp5i/oradata/data01/a_nolog01.dbf';
set newname for datafile 17 to '/tcrp5i/oradata/data01/a_queue01.dbf';
set newname for datafile 18 to '/tcrp5i/oradata/data01/a_queue02.dbf';
set newname for datafile 19 to '/tcrp5i/oradata/data01/a_ref01.dbf';
set newname for datafile 20 to '/tcrp5i/oradata/data01/a_ref02.dbf';
set newname for datafile 21 to '/tcrp5i/oradata/data01/a_summ01.dbf';
set newname for datafile 22 to '/tcrp5i/oradata/data01/a_txn_data01.dbf';
set newname for datafile 23 to '/tcrp5i/oradata/data01/a_txn_data02.dbf';
set newname for datafile 24 to '/tcrp5i/oradata/data01/a_txn_data03.dbf';
set newname for datafile 25 to '/tcrp5i/oradata/data01/a_txn_ind01.dbf';
set newname for datafile 26 to '/tcrp5i/oradata/data01/a_txn_ind02.dbf';
set newname for datafile 27 to '/tcrp5i/oradata/data01/a_txn_ind03.dbf';
set newname for datafile 28 to '/tcrp5i/oradata/data01/a_txn_ind04.dbf';
set newname for datafile 29 to '/tcrp5i/oradata/data01/a_txn_ind05.dbf';
set newname for datafile 30 to '/tcrp5i/oradata/data01/ctxd01.dbf';
set newname for datafile 31 to '/tcrp5i/oradata/data01/odm.dbf';
set newname for datafile 32 to '/tcrp5i/oradata/data01/olap.dbf';
set newname for datafile 33 to '/tcrp5i/oradata/data01/owad01.dbf';
set newname for datafile 34 to '/tcrp5i/oradata/data01/portal01.dbf';
set newname for datafile 35 to '/tcrp5i/oradata/data01/euld01.dbf';
set newname for datafile 36 to '/tcrp5i/oradata/data01/intfd01.dbf';
set newname for datafile 37 to '/tcrp5i/oradata/data01/intfx01.dbf';
set newname for datafile 38 to '/tcrp5i/oradata/data02/sysaux01.dbf';
set newname for datafile 39 to '/tcrp5i/oradata/data01/undo02.dbf';
set newname for datafile 40 to '/tcrp5i/oradata/data01/a_txn_data04.dbf';
set newname for datafile 41 to '/tcrp5i/oradata/data01/a_txn_ind06.dbf';
set newname for datafile 42 to '/tcrp5i/oradata/data02/system12.dbf';
set newname for datafile 43 to '/tcrp5i/oradata/data01/a_ref03.dbf';
set newname for datafile 44 to '/tcrp5i/oradata/data01/xkbd_data01.dbf';
set newname for datafile 45 to '/tcrp5i/oradata/data01/xkbx_ind01.dbf';
set newname for datafile 46 to '/tcrp5i/oradata/data02/sysaux02.dbf';
set newname for datafile 47 to '/tcrp5i/oradata/data01/xxor_01.dbf';
set newname for datafile 48 to '/tcrp5i/oradata/data01/xxord_01.dbf';
set newname for datafile 49 to '/tcrp5i/oradata/data01/xxorx_01.dbf';
set newname for datafile 50 to '/tcrp5i/oradata/data01/xxord_02.dbf';
set newname for datafile 51 to '/tcrp5i/oradata/data01/xxord_03.dbf';
set newname for datafile 52 to '/tcrp5i/oradata/data01/xxorx_02.dbf';
set newname for datafile 53 to '/tcrp5i/oradata/data01/xxorx_03.dbf';
set newname for datafile 54 to '/tcrp5i/oradata/data01/undo03.dbf';
set newname for datafile 55 to '/tcrp5i/oradata/data01/undo04.dbf';
set newname for datafile 56 to '/tcrp5i/oradata/data01/undo05.dbf';
set newname for datafile 57 to '/tcrp5i/oradata/data01/undo06.dbf';
set newname for tempfile 1 to ''/tcrp5i/oradata/data02/temp03.dbf';
set newname for tempfile 2 to '/tcrp5i/oradata/data02/temp02.dbf';
set newname for tempfile 3 to '/tcrp5i/oradata/data02/temp01.dbf';
set newname for tempfile 4 to '/tcrp5i/oradata/data02/temp04.dbf';
set newname for tempfile 5 to '/tcrp5i/oradata/data02/temp05.dbf';
set newname for tempfile 6 to '/tcrp5i/oradata/data02/temp06.dbf';
set until scn 1497768084 ;
duplicate target database to "TCRP5I"
LOGFILE
GROUP 1 ('/tcrp5i/oradata/data03/log1a.dbf',
'/tcrp5i/oradata/data03/log1b.dbf') SIZE 100M,
GROUP 2 ('/tcrp5i/oradata/data03/log2a.dbf',
'/tcrp5i/oradata/data03/log2b.dbf') SIZE 100M,
GROUP 3 ('/tcrp5i/oradata/data03/log3a.dbf',
'/tcrp5i/oradata/data03/log3b.dbf') SIZE 100M;
}

Production rman pieces will be at loation


/porabackup/PCATSI/RMAN on ditcats20
Check if the above path is mounted in the target server.
If not copy required date’s backup pieces to any available
mount point in target and create links as like prod rman
backup locations;
Eg:
On target server, coppied pieces to
/orabackup/dconvi/rman and created link as below.
ditcats30.atlanta.local
$ pwd
/porabackup/PCATSI
$ ls -rlt
total 0
lrwxrwxrwx 1 ordconvi dbdconvi 22 Jan 13 01:45
RMAN -> /orabackup/dconvi/rman
rman_target.sh
rman catalog rmanpcatsi/rmanpcatsi@rman target
sys/Emper0r@pcatsi auxiliary /
cmdfile='/tcrp5i/oracle/tcrp5i_rman.cmd'
log='/tcrp5i/oracle/tcrp5i_rman.log'

3 Add tns entry of source 1.Get the tns entries from source (PROD) and catalog and add
and catalog in the target these entries to target instance tnsnames under $TNS_ADMIN
instance tnsnames.ora
4 Query the catalog for 1.Connect to source and catalog as follows:
backup information
rman target sys/Termina1@pcatsi catalog
rmanpcatsi/rmanpcatsi@rman

rman>list backup;
5 Edit clone_target.rman From the output of the above command choose the latest SCN
We can also use below commands:
Also edit parameter file and
make the suggested Connect ditcats22: sqlplus rmanpcatsi/rmanpcatsi@rman
changes.
Select
db_name,completion_time,thread#,sequence#,first_change#,next
_change# from rc_backup_redolog where trunc(completion_time)
>=trunc(sysdate-1) order by 3,4,2

From above output select last line as scn


number(first_change# column value)

select distinct checkpoint_change#,completion_time from


rc_backup_datafile

Modify the clone_target.rman and put the latest SCN from the
above command.

Allocate 2-4 channels

Parameter file changes:


1)Put the below parameter in parameter file to avoid nfs mount
point issue saying not properly mounted.

event="10298 trace name context forever,level 32"

2) Check the compatible parameter in parameter file and set


to:
SQL> show parameter compat

NAME TYPE VALUE


------------------------------------ -----------
------------------------------
compatible string 10.2.0.3

3)Put the below parameter in parameter file to avoid


Error: ORA-38856: cannot mark instance
UNNAMED_INSTANCE_2 (redo thread 2) as enabled

add below parameter to parameter file:

_no_recovery_through_resetlogs=true

6 Check for the channels 1.check the channel that is being used is that of commvault
We can check this from the log file generated
7 Target database 1) Shutdown both Target instances.
preparation
2) From node 1 startup restrict exclusive
3) drop database (Make sure that all datafiles deleted from the
server)
4) Update below init parameters:(1st node only)
#cluster_database = true
#cluster_database_instances = 2
_no_recovery_through_resetlogs=TRUE
5) Start DB in no-mount stage.
8 Run the script 1.Run the script rman_target.sh
rman_target.sh
2.This script will start the restore
3.Once the restore is done check the status of the database
9 Check the status of 1. Run :
database select count(*) from v$recover_file;
2.Run:
select distinct(status) from v$datafile;

To make sure all the files are online and there are no files that
need recovery
10 Enable RAC(Only for Use the below commands to check log file volumes.
VCATSI & QCATSI) set linesize 200
col MEMBER for a50
select * from v$logfile; ----> Check the group and members
column. Each group will be having one or two members
select * from v$log----------> check thread# Column. it will show
the value 1 now.

Add the logfiles to thread 2 and enable using below steps:-

SQL> ALTER DATABASE ADD LOGFILE THREAD 2


GROUP 4 (
'/vdata02/VCATSI/log4a.log',
'/vdata02/VCATSI/log4b.log'
) SIZE 100M,
GROUP 5 (
'/vdata02/VCATSI/log5a.log',
'/vdata02/VCATSI/log5b.log'
) SIZE 100M,
GROUP 6 (
'/vdata02/VCATSI/log6a.log',
'/vdata02/VCATSI/log6b.log'
) SIZE 100M;

SQL> ALTER DATABASE ENABLE PUBLIC THREAD 2;

Check the thread 2 redologs :

select * from v$logfile; --> Check the group and members


column. Each group will be having one or two members
select * from v$log ; ----------> check thread# Column. It will
show the value 2 now.

Shutdown normal first instance (db1)

Update below init parameters(uncomment)

cluster_database = true
cluster_database_instances = 2

startup the first instance(db1)

startup the second instance(db2)

PING THE NODES & INSTANCES FROM OTHER NODES & INSTANCE
TO CROSS VERIFY THE RAC ENABLING
11 Resize the TEMP CREATE A NEW TEMP3 TABLESPACE AND MAKE IT AS DEFUALT-
tablespace(Size – 10gb)
create temporary tablespace TEMP3 tempfile
'/vdata02/VCATSI/temp01.dbf' size 1800M;
alter database default temporary tablespace temp3;
DROP THE OLD TEMP TABLESPACES-
drop tablespace temp1 including contents and datafiles;
drop tablespace temp2 including contents and datafiles;

CREATE A TEMP1 & TEMP2 with LIMITED SIZE(Total size 10gb)


Eg:
create temporary tablespace TEMP1 tempfile
'/vdata02/VCATSI/temp_01.dbf' size 1800M;
create temporary tablespace TEMP2 tempfile
'/vdata02/VCATSI/temp_02.dbf' size 1800M;

MAKE TEMP1 as default-


alter database default temporary tablespace temp1;

DROP THE TEMP3 TABLESPACE-


drop tablespace temp3 including contents and datafiles;

12 Resize the UNDO Create a undo tablespace as below:-


tablespace(Size-10gb) SQL> create undo tablespace APPS_UNDOTS_1 datafile
'/vdata03/VCATSI/undo_01.dbf' size 1g;

- Shutdown the database


SQL> shut immediate

Change the parameters in init file as below:-


From undo_tablespace = APPS_UNDOTS1
To undo_tablespace = APPS_UNDOTS_1

- Bring up the database


SQL> startup

DROP THE OLD UNDO TABLESPACES-


SQL> drop tablespace APPS_UNDOTS1 including contents and
datafiles;
SQL> drop tablespace APPS_UNDOTS2 including contents and
datafiles;
CREATE NEW UNDO TABLESPACES WITH OLD NAME WITH SIZE OF
10GB(APPROX)
Eg:
SQL> create undo tablespace APPS_UNDOTS1 datafile
'/vdata03/VCATSI/undo01.dbf' size 1800M;
SQL> create undo tablespace APPS_UNDOTS2 datafile
'/vdata02/VCATSI/undo02.dbf' size 1800M;
SQL> alter tablespace APPS_UNDOTS1 add datafile
'/vdata03/VCATSI/undo03.dbf' size 1800M;
SQL> alter tablespace APPS_UNDOTS2 add datafile
'/vdata02/VCATSI/undo04.dbf' size 1800M;
SQL> alter tablespace APPS_UNDOTS2 add datafile
'/vdata02/VCATSI/undo05.dbf' size 1800M;

- Shutdown the database


SQL> shut immediate

Change the paramters in init file as below:-


From undo_tablespace = APPS_UNDOTS_1
To undo_tablespace = APPS_UNDOTS1

- Bring up the database


SQL> startup

DROP OF BELOW UNDO TABLESPACE-


SQL> drop tablespace APPS_UNDOTS_1 including contents and
datafiles;
13 Perform a sanity check of 1.perform a sanity check of the database(check if there are any
the database ORA- errors)
14 Disabling archive log By default rman puts the database in archive log mode
So perform the below steps to put it in noarchivelog(Should be
only if target is run in noarchive log mode)

Sql>shutdown immediate;
Sql>startup mount
Sql>alter database noarchivelog
Sql>alter database open
15 Perform another sanity 1.Perform another sanity check of the database
check

Issues and fixes:

After completion of restore recovery failed with below error.

Error: ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread 2) as enabled


Fix: _No_recovery_through_resetlogs=true

Error: ORA-27061: waiting for async I/Os failed


Fix: DISK_ASYNCH_IO = false

You might also like