Professional Documents
Culture Documents
1-8
Table of Contents
Cloning an Oracle Database.................................................................................................1 Table of Contents.............................................................................................................2 1. Purpose of the document..............................................................................................3 2. Document Usage..........................................................................................................3 3. Overview of the Procedure..........................................................................................3 3.1 Introduction............................................................................................................3 3.2 Environments.........................................................................................................4 3.3 Assumption............................................................................................................4 3.4 Cloning Process.....................................................................................................4 3.4.1 Steps to be followed in Primary database:..........................................................4 3.4.2 Steps to be followed in the Secondary database server:.....................................5 5. Conclusion...................................................................................................................8
2-8
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.
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) b) c) d) You can recover to the most recent time period. Doesnt require outage of the source database Requires less time compared to the other process Best method for large databases
3-8
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.
4-8
2) Edit the pfile as it would be for secondary database server locations a) b) c) d) e) f) Control_files- new locations instance_name new name background_dump_dest new location core_dump_dest- new location user_dump_dest new location log_archive_dest- new location
Save the pfile as init_<SID>.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 <value> 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
5-8
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=<NEW_SID> Sqlplus / as sysdba You will get a Connected to an idle instance message. 7) If UNIX, In the $ prompt give EXPORT ORACLE_SID=<new_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 @<path>/cr_control.sql If Unix @<path>\cr_control.sql if in Unix You should get a message like Control File created
6-8
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.
7-8
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.
8-8