0% found this document useful (0 votes)
137 views

Cloning An Oracle

This document provides steps to clone an Oracle database from a primary database to a secondary database using hot backup recovery. It involves taking a hot backup of datafiles on the primary database, archiving logs, and transferring the backup and logs to the secondary server. The backup and logs are then used to recover the secondary database up to a specified point, after which it can be opened with a resetlogs operation. When complete, the secondary database is an up-to-date clone of the primary database, with no downtime required on the primary system.

Uploaded by

Printesh Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views

Cloning An Oracle

This document provides steps to clone an Oracle database from a primary database to a secondary database using hot backup recovery. It involves taking a hot backup of datafiles on the primary database, archiving logs, and transferring the backup and logs to the secondary server. The backup and logs are then used to recover the secondary database up to a specified point, after which it can be opened with a resetlogs operation. When complete, the secondary database is an up-to-date clone of the primary database, with no downtime required on the primary system.

Uploaded by

Printesh Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Cloning an Oracle Database

Posted by Narashim Reddy .R on July 27, 2009

3 Votes
Table of Contents
1. Purpose of the document
2. Document Usage
3. Overview of the Procedure
3.1 Introduction
3.2 Environments
3.3 Assumption
3.4 Cloning Process
3.4.1 Steps to be followed in Primary database:
3.4.2 Steps to be followed in the Secondary database server:
5. Conclusion
1. This document illustrates a process to clone an Oracle database using hot backup. The
following sections are covered in this document
Overview
Environments
Assumptions
Cloning process
2. Document Usage
This document can be useful for any Oracle DBA for cloning an Oracle database. Generally
cloning databases with the help of source database hot backup is a standard process to
effectively and efficiently create a replica of the source database. The process illustrated in
this document can be used by any DBA who wants to create a replica of an Oracle database
with the help of hot backup and the associated archive logs.
3. Overview of the Procedure
3.1 Introduction

Cloning database is one of the routine DBA activities. Any DBA who administers various
environments and is supporting the application development team for database activities has
to periodically synchronize the acceptance/testing/development with the Production data.
This frequency of synchronization depends upon the business and application development
teams requirements. Generally this process can be done with the below mentioned procedures
1)EXPORT/IMPORT utilities
2)DATA PUMP
3)Cold Backup Restoration
4)Hot Backup Recovery
Each of the above mentioned process has got its own pros and cons. To state a few vital
reasons why Hot backup recovery process is chosen widely
a)You can recover to the most recent time period.
b)Doesnt require outage of the source database
c)Requires less time compared to the other process
d)Best method for large databases
3.2 Environments
1. Primary or the Source database system
2. Secondary or the Target database system
3.3 Assumption
Primary database operated in ARCHIVELOG mode.
Secondary database to be created by cloning in a different server
Primary and Secondary environment Operating system are same.
3.4 Cloning Process
3.4.1 Steps to be followed in Primary database:
1)Perform HOTBACKUP of all the data files
2)LSN number
Login as sys as sysdba
Sql> Alter system archive log current;
Sql> Archive log list
Note down the Current Log Sequence

3)Control file trace


In Sql> prompt issue the statement
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
You can find the trace file in the udump directory.
3.4.2 Steps to be followed in the Secondary database server:
1)If the secondary database is to be created in a different server
FTP the following to a temporary location in the secondary database server.
a)hot backup of all the primary database data files
b)all the archive log files generated in the primary database after you start hot backup
c)control file trace of primary database
d)pfile of the primary database
2)Edit the pfile as it would be for secondary database server locations
a)Control_files- new locations
b)instance_name new name
c)background_dump_dest new location
d)core_dump_dest- new location
e)user_dump_dest new location
f)log_archive_dest- new location
Save the pfile as init_.ora in
$ORACLE_HOME/dbs directory if UNIX
$ORACLE_HOME\database if WINDOWS
Where SID is the instance name given above in the edited pfile
3) In the control file trace Use the SET #2. RESTLOGS case CREATE CONTROLFILE
section (Since we dont use the primary database redolog files, we use this option). In that
section Copy from CREATE CONTROLFILE to CHARACTER SET to another file.
Save the file as cr_control.sql
Edit the following section in cr_control.sql
a)Use SET instead of REUSE

Old: CREATE CONTROLFILE REUSE DATABASE <PRIMARY_DBNAME


>RESETLOGS
NEW: CREATE CONTROLFILE SET DATABASE <SECONDARY_DBNAME>
RESETLOGS
b)Edit the LOGFILE paths as per the secondary database environment
c)Edit the DATAFILE paths as per the secondary database environment
d)Save the cr_control.sql file
4) Move the ftp ed Hot backup DATAFILE from temporary location of specific location as
specified in the control file cr_control.sql
5) Move the archived logs from temporary location to the location specified in
log_archive_dest in pfile
6) If Windows,
Create an oracle service using ORADIM utility
ORADIM -NEW -SID sid | -SRVC service [-INTPWD password] [-MAXUSERS number] [STARTMODE a|m] [-PFILE file] [-TIMEOUT secs]
In the CMD prompt
SET ORACLE_SID=
Sqlplus / as sysdba
You will get a Connected to an idle instance message.
7) If UNIX,
In the $ prompt give
EXPORT ORACLE_SID=
Sqlplus / as sysdba
You will get a Connected to an idle instance message.
8)In the SQL> Prompt give
STARTUP NOMOUNT

9) Run the cr_control.sql file in the SQL> prompt


If Windows
@/cr_control.sql
If Unix
@\cr_control.sql if in Unix
You should get a message like Control File created
9) Recover the database using backup control file. In the SQL> prompt give
RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
Note: this can also be done with UNTIL TIME or UNTIL SCN provided you know the time
or the SCN until which you want to perform the recovery
10)The recovery process will keep prompting for archive logs. Give return for each prompt of
archive log.
Since the required archive logs from Primary database are restored in archive_log_dest of
secondary, it will get applied for every return you give in the prompt.
Once the recovery process prompts for the archive log with the LSN number noted in the
Primary database,
in step 2) of Steps to be done in Primary database section
Give CANCEL in the recovery sql prompt
11)Now you must get a message like
Media recovery cancelled.
12) Now in the SQL prompt give.
ALTER DATABASE OPEN RESETLOGS;
You should get a message like.
Database opened.
12)Bounce the database

SHUTDOWN IMMEDIATE;
STARTUP;
13)Check for errors in bdump.
14)Check log switch.
15)Check redo log archival
16)Compare the users, objects, size with the Primary database
17)Take a complete cold back up and maintain that as generation 0 backup.
You have cloned the database.
5. Conclusion
Hot backup recovery is one of the best methods to clone database because there is no outage
or down time required in the primary database and data is replicated in secondary database to
the most recent time period.

You might also like