Pages

Wednesday, January 7, 2015

Database Cloning

Contents:- Cloning Requirements,  Cloning Database in Different Ways, Database Refresh


Cloning Concepts
              In Simple Words, Database Cloning means a copy of an Existing database.

Requirements

 ü  Creating a copy of a production system for testing updates.
 ü  Migrating an existing system to a new hardware
 ü  Creating a Stage Area to reduce patching downtime
 ü  Relocating an Oracle Database to another machine
 ü  Renaming an Oracle Database using resetlogs

Cloning General Steps

 è Taking the backup of source database or primary database.
 è Copy the backup piece to the target server.
 è Start the auxiliary instance on the target
 è Create the controlfile
 è Restore the database from backup.
 è Open the database.



 1.   Database Cloning Using Template ( Source Database will be shutdown during template creation)
Source Server Side
Create a Template From Source Database.
  Target Server Side
          Create Database using Created Template from Source Database.

 2.   Database Cloning Using Using Logical Backup (Import / Export)
          It will not export data dictionary like dba_,user_,all_



 3.   Database Cloning Using RMAN or Hot Backup (Online Backup). For this Production Database must be in archivelog mode.

Target DB:- ORCL
Auxiliary DB:- clonedb

Steps

ORCL

 è Take Fresh Backup of database by using following script.
 è $>. Oraenv
 orcl
 è $>rman target /
Rman>run
{
Allocate channel c1 type disk;
Backup database format ‘/u01/app/oracle/backup/db_%u_%d_%s’;
Sql ‘alter system  archive log current’;
Backup format ‘/u01/app/oracle/backup/archivelog/log_t%t_s%s_p%p’
(archivelog all delete all input);
};

 è Create new file for newly clone database from an existing database spfile.
SQL> create pfile=’/u01/app/oracle/initclonedb.ora’ from spfile;



CLONEDB

 è By network sharing copy newly created backup of target (orcl) database to the auxiliary machine (clonedb) as same location of target machine.

 è Create directory Structure for clone database.

 è Change pfile .
$>vi /u01/app/oracle/initclonedb.ora
:1,$ s#orcl#clonedb#g
Change following parameters if u are doing on (before 11g with no asm)
*.DB_FILE_NAME_CONVERT=('D:\app\xp\oradata\orcl2','D:\app\xp\oradata\dup')
*.LOG_FILE_NAME_CONVERT=('D:\app\xp\oradata\orcl2','D:\app\xp\oradata\dup'

 è Create Password file for auxiliary database
$>orapwd file=’$ORACLE_HOME/dbs/orapwclonedb.ora’ password=clonedb entries=10

 è Create spfile for auxiliary database.
$sqlplus sys as sysdba
Sql> create spfile=’+data/clonedb/spfileclonedb.ora’ from pfile=’/u01/app/oracle/initclonedb.ora’

 è Create Pfile into dbs folder to call spfile of auxiliary database in oracle 11g
$vi $ORACLE_HOME/dbs/initclonedb.ora
Spfile=’+data/clonedb/spfileclonedb.ora’;

 è Start auxiliary database by created spfile
$>. Oraenv
Clonedb

$sqlplus sys as sysdba

sql>startup nomount

 è Now connect to auxiliary database and target database and restore backup to auxiliary database by using duplicate command.

$> . oraenv
Cloned
$>rman /
Rman>connect auxiliary /
Rman> connect target sys/orcl@orcl
Rman>duplicate target database to clonedb;

Cloning Finish.


 4.   Database Cloning using Cold (Offline) Backup by using OS Command

Steps

 è Copy database files by operating system copy and paste command from source database to target database
 è Change pfile.
 è Sql>startup nomount
 è Create controlfile by using controlfile script
 è Sql>alter database open;



Database Refresh

Database Refresh is also referred to as a database clone. However we don’t clone oracle home rather we clone the database  as refresh.

Refreshing the database is like applying the changes or updates or production database to the database where the database is already cloned.

Refreshing of a particular table, group of tables, schema or tablespace will be done using traditional export/ import. Transportable tablespace or data pump methods.

The main difference between database cloning and database refreshing is Cloning process includes oracle home and database clone; where as refreshing process only includes database clone.

i.e if you applied patch in production then you need to do database cloning because patch applied into oracle_home so.


No comments:

Post a Comment