Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
CLONING ORACLE DATABASE (DIFFERENT DIRECTORY STRUCTURE )
Database cloning is creating a Identical copy of existing database. It can be done on separate hosts or on the same host. This article is wished-for as a brief guide to clone Oracle database from one server to another server. I will show how to clone database using HOT backup. HOT cloning is very easier to clone by using OS commands. HOT cloning requires database recovery. To get insight about HOT BACKUP HIT HERE.
Source database name : sham on OEL5.SERVER1.COM Clone database name : rose on OEL5.SERVER2.COM SOURCE IP : 192.168.241.131 SERVER1
TARGET IP : 192.168.241.132 SERVER2
CHECKING IPADDRESS FOR SERVER1 & SERVER2
SERVER 1
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
CHECK NETWORK AVAILABILITY BETWEEN TWO SERVERS SERVER 1
SERVER 2
CREATE DIRECTORIES FOR ADMIN LOG FILES $ mkdir –p /u01/app/oracle/admin/rose/ $ mkdir –p /u01/app/oracle/admin/rose/adump $ mkdir –p /u01/app/oracle/admin/rose/bdump $ mkdir –p /u01/app/oracle/admin/rose/cdump $ mkdir –p /u01/app/oracle/admin/rose/udump
CREATE DIRECTORIES FOR CRD FILES AND ARCHIVELOGS
$ mkdir –p /u01/app/oracle/oradata/rose
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
CREATING NECESSARY DIRECTORIES FOR CLONE DATABASEExploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
COPYING PFILE FROM SEVER1 TO SERVER2Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
CHECKING ARCHIVELOGS DETAILSExploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
COPYING *.dbf FILES TO CLONE SERVERExploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
CHECKING FRA FOR SOURCE DATABASE
COPYING ALL ARCHIVES FROM SOURCE TO DESTINATION
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
CHECKING TARGET SERVERCREATING CONTROLFILE SCRIPT
The word 'REUSE' needs to be changed to 'SET'. The database name needs setting to the new database name (if it is being changed). You can decide whether the database will be put into archivelog mode or not.
Remove any lines that start with -- Remove any lines that start with a #
Remove any blank lines in the 'CREATE CONTROLFILE' section. Remove the line 'RECOVER DATABASE USING BACKUP CONTROLFILE' Remove the line 'ALTER DATABASE OPEN RESETLOGS;’
$ ls -l /home/oracle/trace.sql
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
NEWLY CREATED PFILE FOR CLONE DATABASEI am using pfile, I have placed initrose.ora file under $ORACLE_HOME/dbs directory. According to clone database, i made some changes related to clone database in init.ora file. ( Location of control file path, audit_file_dest, background_dump_dest core_dump_dest, user_dump_dest, db_name , etc ).
$ cd /u01/app/oracle/product/10.2.0/db_1/dbs/ [oracle@oel5 dbs] $ ls -l initrose.ora
-rwxrwxr-x 1 oracle oinstall 1038 Oct 27 18:08 initrose.ora
$ cd /u01/app/oracle/oradata/hotbkp $ cp * /u01/app/oracle/oradata/rose/
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
PHYSICAL DATAFILES IN CLONE SERVERSTARTING CLONE DATABASE & RECREATING CONTROL FILE
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
APPLYING REQUIRED ARCHIVED LOGSAPPLYING SEQUNCE - 4
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
APPLYING SEQUNCE 7 & SEQUENCE 8Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
HOT CLONING ( SAME DIRECTORY STRUCTURE ) Source database name : sham
Clone database name : rose
To maintain Admin related files
Source database path=/u01/app/oracle/admin/sham/ Clone database path=/u01/app/oracle/admin/sham/
To maintain Physical files
Source database path=/u01/app/oracle/oradata/sham/ Clone database path=/u01/app/oracle/oradata/sham/ SOURCE IP : 192.168.241.131 SERVER1
TARGET IP : 192.168.241.132 SERVER2
Source database name : sham on OEL5.SERVER1.COM Clone database name : sham on OEL5.SERVER2.COM
HOT backup cloning, in same directory structure is almost similar to different directory structure. What we have seen above.
Few changes are required. They are NOT required to recreate controlfile for clone database. We can copy all controlfiles from source server to clone server ( along with datafiles and all required archives).
STEPS TO PERFORM HOT CLONING (SAME DIRECTORY STRUCTURE)
Create same directory structure in clone server.
Create pfile from spfile in source server and copy to clone server. Put source database in ‘begin backup mode’.
Copy *.dbf files to clone sever from source server. Release source database from begin backup mode.
Make log switches to get current archives in FRA for recovery purpose. Copy *.ctl files to clone sever from source server.
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
CREATING DIRECTORIES FOR C/R/D FILES
PUTTING SOURCE DATABASE IN BEGIN BACKUP MODE
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
COPYING *.dbf FILES TO CLONE SERVERExploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
RELEASING SOURCE DATABASE FROM BEGIN BACKUP MODECOPYING ALL CONTROL FILES TO CLONE SERVER
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
STARTUP CLONE DATABASESYS>recover database using backup controlfile until cancel;
ORA-00279: change 390017 generated at 11/05/2014 16:16:45 needed for thread 1 ORA-00289: suggestion:
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_05/o1_mf_1_1_b5n0l6f2_.arc ORA-00280: change 390017 for thread 1 is in sequence #1
Specify log: {<RET>=suggested | filename | AUTO | CANCEL} auto
ORA-00279: change 395354 generated at 11/05/2014 16:26:04 needed for thread 1 ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_05/o1_mf_1_2_b5n0lnrr_.arc ORA-00280: change 395354 for thread 1 is in sequence #2
ORA-00278: log file
'/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_05/o1_mf_1_1_b5n0l6f2_.arc' no longer needed for this recovery
.. ...
[Trimmed]
ORA-00279: change 396250 generated at 11/05/2014 16:26:19 needed for thread 1 ORA-00289: suggestion:
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_05/o1_mf_1_3_b5n0ntjc_.arc ORA-00279: change 407663 generated at 11/05/2014 16:45:37 needed for thread 1
ORA-00289: suggestion:
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_05/o1_mf_1_11_%u_.arc ORA-00280: change 407663 for thread 1 is in sequence #11
ORA-00278: log file
'/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_05/o1_mf_1_10_b5n1psc0_.arc' no longer needed for this recovery
Exploring the Oracle DBA Technology by
Gunasekaran , Thiyagu
ORA-00308: cannot open archived log
'/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_05/o1_mf_1_11_%u_.arc' ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory Additional information: 3
SQL> alter database open resetlogs; Database altered.