Oracle 11g RMAN Cloning using Backup Duplicate command

11g RMAN Cloning using Duplicate Command


Today I was given a task to perform Rman cloning from server prod to Dev.

NOTEHere i'm doing backup based Duplication instead of Active duplication (NO backup method)

Here my DEV server is already identical to prod except with a data in it Since my both prod and dev server are 11gr2 I decided to go with Rman Duplicate Command, even though  we can go either for Data Pump  or Rman or Manual Copy(cp) methods but my prod size is around 2TB so Rman is a better solution for it(since its fast and recommended)

SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 – Production

$ cat    /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)


Step 1:   Take the backup of the prob server either HOT or COLD (I did cold) depending upon your situation
For a cold backup
SQL>   shutdown Immediate;
SQL>   Startup mount;

And connect to RMAN (I have no catalog)

Rman target / nocatalog
Rman > configure controlfile autobackup on;

Allocate more channels depending upon number of CPU’s available on your database, here I used 12 channels

RMAN >   configure device type disk parallelism 12 backup type to backupset;
RMAN>   show all ;
RMAN configuration parameters for database with db_unique_name PROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 12 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/11.2.0.2/dbs/snapcf_PROD.f'; # default

Rman >  run {
2>  allocate channel d1 type disk;
3> Backup full tag full_offline_bkup
4> Format ‘/var/backup/corppsdb/rman/db_t%t_s%s_p%p’
5> Database plus archivelog;
6> Release channel d1;
}

If you write a script like above then Rman uses only 1 channel even though you set it for 12 paths by default.

Rman >  run {
2>Backup full tag full_offline_bkup
3> Format ‘/var/backup/corppsdb/rman/db_t%t_s%s_p%p’
4> Database plus archivelog;
}

Now it uses 12 channels…….

It took me around 12 hrs. to complete backup to the file location specified (12 backup sets created)

STEP 2 :  Move all the backup sets to the DEV server using either SCP or SFTP or FTP Or whatever you are convenient to a specific location

STEP 3 :   Restore all the data into the DEV server using RMAN Duplicate Command

Before Doing RMAN Duplication makes sure you have TNS entry of prod in DEV server
Go to the $ORACLE_HOME/network/admin location and open tnsnames.ora file and see if not there copy from prod and put in dev  tnsnames.ora file

I already have both Parameter file and Controlfile in DEV server but if you don’t have you need to create pfile and controlfile which is same as like PROD pfile and controlfile, for this you need to copy pfile and controlfile from prod and change all parameters according to the DEV

The two main mandatory parameters we need to change in DEV are

db_file_name_convert=(,)
log_file_name_convert=(,)

Password file also should create in $ORACLE_HOME/dbs

orapwd file=${ORACLE_HOME}/dbs/orapw${ORACLE_SID} password=

Then shut down and startup dev in NOMOUNT again…..

SQL >   shut immediate;
SQL >   startup nomount;

RMAN    target      sys/passwd@prod
RMAN >   connect auxiliary /                              --->  connecting to target
RMAN>   show   all;                    (just to check everything)

RMAN>   run {
2>   set until time =’ sysdate  –  1’;
3>   Duplicate target database to aux_database_name nofilenamecheck;
}
...........
.......
database opened
Finished Duplicate Db at 09-DEC-11

Now my dev database is exact copy of prod database.

If you want to see the Converter parameters in pfile or spfile

SQL> show parameter convert

NAME                                         TYPE           VALUE
------------------------------------ ----------- ------------------------------
_convert_set_to_join                 boolean     FALSE
db_file_name_convert                 string      +DATA/PROD/DATAFILE/, +DATA/DEV/DATAFILE/
log_file_name_convert                string      +DATA/PROD/ONLINELOG/, +DATA/DEV/ONLINELOG/             

  See: RMAN 'Duplicate From Active Database' Feature in 11G (Doc ID 452868.1)        

No comments: