database cloning using cold backup
TRANSCRIPT
DATABASE CLONING USING COLD BACKUP | LINUX
CLONING ORACLE DATABASE FROM SERVER TO SERVER
ABOUT DATABASE CLONING
Database cloning is creating a Identical copy of existing
database. It can be done on separate hosts or on the same
host.
WHY CLONING ?
Every company will have PRODUCTION | TESTING| DEVELOPMENT
database. Some times development and production
environment there will become need to transport the entire
database from one physical machine to another. This copy may
be used for development, production testing, beta testing,
etc ..
1) If DBA wants to change dbname or DBID of the database.
2) Relocating an Oracle database to another machine.
3) Moving Oracle database to new Storage media.
THREE WAYS TO CLONE A DATABASE
COLD CLONING HOT CLONING RMAN CLONING
This article is intended as a brief guide to clone Oracle
database from server to server. I will show how to clone
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
database using cold cloning. Cold cloning is very easier to
clone by using OS commands.
Cold cloning does NOT require database recovery because the
source database is shut down normally before the image is
created.
COLD BACKUP CLONING SAME DIRECTORY STRUCTURE.
BUT DIFFERENT SERVER
SOURCE DATABASE : orcl
TARGET DATABASE : clone
SOURCE IP : 192.168.1.200 SERVER01
TARGET IP : 192.168.1.168 SERVER02
SOURCE DATABASE FILES PATH : /u01/app/oracle/oradata/orcl
TARGET DATABASE FILES PATH : /u01/app/oracle/oradata/clone
CHECKING IPADDRESS FOR SOURCE MACHINE - SERVER01
$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:23:9F:47
inet addr:192.168.1.200 Bcast:192.168.1.255 Mask:255.255.255.0 . .. [ Trimmed ]
CHECKING IPADDRESS FOR TARGET MACHINE - SERVER02
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:01:A9:D2
inet addr:192.168.1.168 Bcast:192.168.1.255 Mask:255.255.255.0 . .. [ Trimmed ]
STARTUP THE SOURCE DATABASE ( IF NOT OPEN )
$ export ORACLE_SID=orcl
$ sqlplus /nolog
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started....
[ Trimmed ].
Database opened.
IDENTIFY THE PATH AND NAMES OF DATABASE FILES
( DATAFILES, CONTROL FILES, AND REDO LOG FILES )
SQL> select name from v$datafile;
SQL> select name from v$controlfile;
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
SQL> select member from v$logfile;
http://www.scribd.com/doc/187563299/Identify-the-Path-and-Names-of-Database-Files
TAKE CONTROL FILE BACKUP
Create a control file for the clone database. To do this, from the
source database and request a dump of the current control
file. The file will require extensive editing before it can be used.
By default , trace goes to USER_DUMP_DEST. We can check the
path. SQL> show parameter user_dump_dest ;
I am taking trace file at specific path ---
SQL> alter database backup controlfile to trace as 'path ' ;
alter database backup controlfile to trace as
'/u01/backup/ctrl.sql'; Database altered.
PARAMETER FILE BACKUP
If database is using pfile, use OS command to copy the pfile
to a backup location. In my case i am using spfile. I will
create pfile from the spfile.
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
PLEASE NOTE
Once created, the new pfile will need to be edited. The cloned
database will be new name, this will need to be changed .
Review the contents of the file and make alterations as
necessary.
SHUTDON THE SOURCE DATABASE
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
CREATE DIRECTORIES FOR CLONE DATABASE - SERVER02
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
MOVING TRACE FILE AND PFILE FROM SOURCE TO TARGET
SQL> cd /u01/backup/
$ ls -l
-rw-r--r-- 1 oracle oinstall 5799 Oct 24 00:07 ctrl.sql
-rw-r--r-- 1 oracle oinstall 995 Oct 24 00:29 initclone.ora
TAKING CLOD BACKUP OF THE SOURCE DATABASE
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
I RECEIVED ALL DATABASE FILES - IN SERVER02
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
EDIT THE CLONE DATABASE PARAMETER FILE
$ cd $ORACLE_HOME/dbs
[oracle@oel5 dbs]$ ls -l clone*
-rw-r--r-- 1 oracle oinstall 995 Oct 24 01:16 clone.ora
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
As i said , pfile will need to be edited so i want to edit it as
per target database (clone). See both screen shots.
Now i am going to edit trace file located at $HOME
Remove all lines from the top of the file up to but not including
the second 'STARTUP MOUNT
Remove any lines that start with --
Remove any lines that start with a #
Remove any blank lines in the 'CREATE CONTROLFILE' section.
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
Remove the line 'RECOVER DATABASE USING BACKUP CONTROLFILE'
Move to the top of the file to the 'CREATE CONTROLFILE' line. The word
'REUSE' needs to be changed to 'SET'. Decide whether the database will be
put into archivelog mode or not.
HOW THE FILE WOULD LOOK FOR A CLONE DATABASE
POINTS TO REMEMBER
Cold cloning does NOT require database recovery because the
source database is shut down normally before the image is
created. So i choosing NOARCHIVELOG mode. If you wish to
change , just change as ARCHIVELOG . This is suffice.
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
Edit the /etc/oratab (or /opt/oracle/oratab) and add an entry for
the clone database. This is also part of the database
environment.
CREATE A PASSWORD FILE at $ORACLE_HOME/dbs
Create password file using oratab utility
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapw$ORACLE_SID password=<password> entries=n
$ orapwd file=orapwclone password=clone entries=3
Oracle exatly needs $ORACLE_SID PREFIX init. so i am
changing
parameter file name from initclonedb.ora to initclone.ora
$ ls -l initclone*
-rw-r--r-- 1 oracle oinstall 1037 Oct 23 00:36 initclonedb.ora
[oracle@oel5 dbs]$ mv initclonedb.ora initclone.ora
ls -l initclone*
-rw-r--r-- 1 oracle oinstall 1037 Oct 23 00:36 initclone.ora
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
CHECKING CLONE DATABASE FILES
CHECK DBID , DBNAME fOR TARGET DATABASE
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
Above screen for target database. We need to change DBID because it is
having source database DBID. HOW TO CHANGE DBID CLICK HERE ..
SCREEN SHOT FOR SOURCE DATABASE
PERFORM FEW CHECKS IN TARGET DATABASE
Make sure all datafiles are okay ..
SQL> select distinct status from v$datafile;
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
STATUS
ONLINE
SYSTEM
It should return only ONLINE and SYSTEM.
SQL> create spfile from pfile='/ path of the pfile ' ;
File created.
SQL> startup force;
ORACLE instance started.
...
[Trimmed].
POINTS TO NOTE :
Change the database ID If RMAN is going to be used to back-
up the database, the database ID must be changed. If RMAN
isn't going to be used, there is no harm in changing the ID.
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu
DATABASE CLONING USING COLD BACKUP | LINUX
Now , Cloned destination database is ready to be
used.
POINTS TO NOTE :
During cold clone , we can do EITHER restore (copy back)
control file or create control file . Yes , if we have same
locations in clone server as source, then we do NOT need to
create control file again just copy all files then start
database.
REFERENCE LINK :
http://www.scribd.com/doc/187550497/Cloning-Oracle-Database-From-Server-to-
Server
Exploring the Oracle DBA Technology by Gunasekaran ,Thiyagu