RMAN Clone v1.0

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 10

CLONING USING RMAN BACKUP

Auth
Document Control

Documents Followed

Sl no. DOC Id. Description

3
4

Reviewers

Name Position
Notation Meaning
SOURCE PRODUCTION (WPROD)
TARGET Instance which has to be cloned (Duplicated) TPROD
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

3. Edit the spool file with the target datafile location paths

Location for each environment that we support.


Means to check that there is sufficient space in the mount-points
before the RMAN clone is run.

3 Init.ora modifications on 1.create pfile from spfile as below


target
Create pfile=’/tmp/inittprod.ora’ from spfile;
Move the spfile to different name and copy the init.ora from the
temp location to $ORACLE_HOME/dbs
2.check if the below parameters exists if not add.
Check if the compatible parameter in parameter file set to 10.2.0.2 or 10.2.0.3
or 10.2.0.4
b) _no_recovery_through_resetlogs=true ---- For error Below
“Error: ORA-38856: cannot mark instance UNNAMED_INSTANCE_2
(redo thread 2) as enabled”
3.Check the undo_tablespace parameter , for the non rac instances this
will be set to apps_unodts. Change this value to apps_undots1 or
apps_undots2

4a Use the attached script 1.Once edited append other lines in the file (clone_target.rman)
as reference taking attached script as reference
rman.cmd
run
{
allocate AUXILIARY CHANNEL c1 type 'SBT_TAPE';
allocate AUXILIARY CHANNEL c2 type 'SBT_TAPE';
allocate AUXILIARY CHANNEL c3 type 'SBT_TAPE';
allocate AUXILIARY CHANNEL c4 type 'SBT_TAPE';
SEND 'NB_ORA_CLIENT=sjdbpr584a.corp.webex.com';
set newname for datafile 1 to '/data01/oradata/TPROD/system01.dbf';
set newname for datafile 2 to '/data01/oradata/TPROD/system02.dbf';
set newname for datafile 3 to '/data01/oradata/TPROD/system03.dbf';
set newname for datafile 4 to '/data01/oradata/TPROD/sysaux01.dbf';
set newname for datafile 5 to '/data01/oradata/TPROD/undotbs101.dbf';
set newname for datafile 6 to '/data01/oradata/TPROD/xxhyp1x01.dbf';
set newname for datafile 7 to '/data01/oradata/TPROD/xxhyprptx01.dbf';
set newname for datafile 8 to '/data01/oradata/TPROD/xxhypsysx01.dbf';
set newname for datafile 9 to '/data01/oradata/TPROD/ctxd01.dbf';
set newname for datafile 10 to '/data01/oradata/TPROD/jld01.dbf';
set newname for datafile 11 to '/data01/oradata/TPROD/ieud01.dbf';
set newname for datafile 12 to '/data01/oradata/TPROD/gmld01.dbf';
set newname for datafile 13 to '/data01/oradata/TPROD/xtrd01.dbf';
set newname for datafile 14 to '/data01/oradata/TPROD/mstx01.dbf';
set newname for datafile 15 to '/data01/oradata/TPROD/jlx01.dbf';
set newname for datafile 16 to '/data01/oradata/TPROD/igfd01.dbf';
set newname for datafile 17 to '/data01/oradata/TPROD/clr_idx01.dbf';
set newname for datafile 18 to '/data01/oradata/TPROD/jtmd01.dbf';
set newname for datafile 19 to '/data01/oradata/TPROD/amvd01.dbf';
set newname for datafile 20 to '/data01/oradata/TPROD/amvx01.dbf';
set newname for datafile 21 to '/data01/oradata/TPROD/oked01.dbf';
set newname for datafile 22 to '/data01/oradata/TPROD/msdd01.dbf';
set newname for datafile 23 to '/data01/oradata/TPROD/igix01.dbf';
set newname for datafile 24 to '/data01/oradata/TPROD/fvx01.dbf';
set newname for datafile 25 to '/data01/oradata/TPROD/drsys01.dbf';
set newname for datafile 26 to '/data01/oradata/TPROD/cctx01.dbf';
set newname for datafile 27 to '/data01/oradata/TPROD/asgd01.dbf';
set newname for datafile 28 to '/data01/oradata/TPROD/ahld01.dbf';
set newname for datafile 29 to '/data01/oradata/TPROD/ieux01.dbf';
set newname for datafile 30 to '/data01/oradata/TPROD/gmsx01.dbf';
set newname for datafile 31 to '/data01/oradata/TPROD/cspx01.dbf';
set newname for datafile 32 to '/data01/oradata/TPROD/lnsx01.dbf';
set newname for datafile 33 to '/data01/oradata/TPROD/iemd01.dbf';
……………………………etc. (the lines in blue italics are obtained from the query in step
2)
set until sequence xxxx thread yyyy;
where xxxx is the sequence number and yyyy is the tread number and xxxxxx ,yyyy are
determined from step 4b or 4c as required.
duplicate target database to "TPROD"
LOGFILE
GROUP 1 (
'/data01/oradata/TPROD/redo1a.log',
'/data02/oradata/TPROD/redo1b.log'
) SIZE 512M,
GROUP 2 (
'/data01/oradata/TPROD/redo2a.log',
'/data02/oradata/TPROD/redo2b.log'
) SIZE 512M,
GROUP 3 (
'/data01/oradata/TPROD/redo3a.log',
'/data02/oradata/TPROD/redo3b.log'
) SIZE 512M;
}
Note:
In the above rman.cmd script mention the below command as per the
source server. If we are doing cloning from WPROD to test server the
below parameter should be
Eg:
SEND 'NB_ORA_CLIENT=sjdbpr584a.corp.webex.com';

4b Resotring the database to 1.Determine the point upto which media recovery should run on the
the point of rman backup restored database.
completion.
RMAN> list backup of archivelog all ;

List of Archived Logs in backup set 9


Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
---- ------- ---------- --------- ---------- ---------
1    56      214541     01-FEB-07 226238   01-FEB-07
1    57      226238     01-FEB-07 226240   01-FEB-07
1    58      226240     01-FEB-07 233107    12-FEB-07
2    1       186185     28-JAN-07 225714     01-FEB-07
2    2       225714     01-FEB-07 226037    01-FEB-07
2    3       226037     01-FEB-07 233110    12-FEB-07

Check the last archive sequence for all redo threads and select the
archive sequence having LEAST "Next SCN" among them. In our
case sequence 58 of thread 1 has Next SCN of 233107 while
sequence 3 of thread 2 has Next SCN of 233110. Since squence 58
of thread 1 has least Next SCN we will recover upto this point. (If you
are keen to have recovery run until some specific time you can always
give SET UNTIL TIME)

2. Since we determined previously that media recovery should run


until sequence 58 hence we use SET UNTIL SEQUENCE 59 (+1)

4c Find the SCN or Time to 1.Take the archive log RAM backup.
recover upto certain time
after RMAN backup Once archival backup completes
completes
2.Determine the point upto which media recovery should run on the
restored database.
RMAN> list backup of archivelog all;

List of Archived Logs in backup set 9


Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
---- ------- ---------- --------- ---------- ---------
1   56      214541     01-FEB-07 226238   01-FEB-07
1   57      226238     01-FEB-07 226240   01-FEB-07
1   58      226240     01-FEB-07 233107    12-FEB-07
2   1       186185     28-JAN-07 225714     01-FEB-07
2   2       225714     01-FEB-07 226037    01-FEB-07
2   3       226037     01-FEB-07 233110    12-FEB-07

Check the last archive sequence for all redo threads and select the
archive sequence having LEAST "Next SCN" among them. In our
case sequence 58 of thread 1 has Next SCN of 233107 while
sequence 3 of thread 2 has Next SCN of 233110. Since squence 58
of thread 1 has least Next SCN we will recover upto this point. (If you
are keen to have recovery run until some specific time you can always
give SET UNTIL TIME)

2. Since we determined previously that media recovery should run


until sequence 58 hence we use SET UNTIL SEQUENCE 59 (+1)

5 Prepare the rman script rman_target.sh


[Don’t run as yet]
rman catalog rman/rman@rcat target sys/xxxx@wprod1
auxiliary / cmdfile='rman.cmd' log='rman_tprod.log'
6 Add tns entry of source 1.Get the tns entries from source (WPROD) and catalog and add
and catalog in the target these entries to target instance tnsnames under $TNS_ADMIN
instance tnsnames.ora
After adding the entries in the above file, check whether we can
able to connect to both the database production and catalog .
rman catalog rman/rman@rcat target sys/xxxx@wprod1
The above command will connect to the catalog database and
production database.
You can see the messge like:
Connected to the target database: WPROD
Connected to the Recovery catalog database:

7 Startup the target DB in DB should have been started in no-mount state


“NOMOUNT” for Restore on target:
For RAC to NON-RAC follow below steps:
SQL>STARTUP NOMUNT
For RAC to RAC follow below steps:
Comment all the RAC parameters and start in nomount mode.
#*.cluster_database_instances=2
#*.cluster_database=TRUE
#TPROD2.instance_name='TPROD2'
#TPROD2.instance_number=2
8 a Run the script Note: DB should have been started in no-mount state:
rman_target.sh
Run the script rman_target.sh prepared in step#5
Eg: nohup sh rman_target.sh > &
2. This script will start the restore and recovers the db and
changes the dbid.
Eg: contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 13-JAN-11
Recovery Manager complete.

3.Once the restore is done check the status of the database and
restore logfile for error.
b Check the status of 1. Run:
database select count(*) from v$recover_file;
2.Run:
select distinct(status) from v$datafile;
select count(*) from dba_data_files; ----To compare with
production.

TO make sure all the files are online and there are no files that
need recovery
9 Perform a sanity check of 1.perform a sanity check of the database (check if there are any
the database ORA- errors)

10 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

11 Create spfile from pfile 1.SQL>create spfile from pfile;


2.SQL>shutdown immediate;
3.SQL>startup;
Include a check to ensure that spfile is being used and not pfile
In the cloning document add steps to restore the init.ora and spfile
from the backup.

You might also like