You are on page 1of 2

Oracle Database Cloning:Larry CattLarry.catt@platinumsolutions.

comCloning and 10g DBCA:With the release of 10g, a database can be cloned from one location to another by use of the Oracle database Creation Assistant. However, this feature along with many of thenew 10g features is worrisome to the veteran database administration crowd. The mainreason for this worry is the lack of knowledge our junior associates are getting due to thenew EM tool. They are not able to function in a telnet environment and trying to getthem to perform any tasks using SQL*Plus is nearly impossible. Do not miss our point.The new EM tool provided by Oracle is a great improvement over past enterprisemanager versions, however every tool has its place and a DBA must know far more thana GUI. The instruction set detailed below for the cloning of an oracle database is valid inmultiple versions of Oracle from 8.1.5 to 10g and has the added benefit of beingperformed over a telnet or ssh connection.Reason for Cloning:In every oracle development and production environment there will become the need totransport the entire database from one physical machine to another. This copy may beused for development, production testing, beta testing, etc, but rest assured that this needwill arise and management will ask you to perform this task quickly. Listed below arethe most typical uses:1. Relocating an Oracle database to another machine.2. Moving Oracle database to new Storage media.3. Renaming Oracle database. Instructions: 1. Ensure that your database is recoverable back to original location and state by backingit up before executing this procedure:Database in NON-ARCHIVE LOG MODE - take an off-line database backup.Database in ARCHIVELOG MODE - take an on-line or off-line database backup.2. Connect to sql*plus as the user SYS AS SYSDBA and ensure that all users havelogged off the system by executing the following command. SQL> connect / as sysdbaConnected.SQL> select username from v$session;SQL> select username from v$session;USERNAME------------------------------

SYS8 rows selected.SQL> You should see several fields returning with no username (these are internal oracle loginsand the will not affect your operations) and one SYS login (this is you).3. Place the system in restricted mode: SQL> alter system enable restricted session;System altered. 4. Connect as SYS with SYSDBA privileges and execute the following SQL command: SQL> connect / as sysdbaConnected. SQL> alter database backup controlfile to trace; OR SQL> alter database backup controlfile to trace as /u01/bkp/controlbkp.sql The [alter database backup controlfile to trace;] command will generate a SQL script thatcan be used to regenerate the controlfile of the database.5. Execute the sql*plus command show parameter <parameter_name> to find your user dump directory. SQL> show parameter user_dump_destNAME TYPE VALUE-------------------------- ----------- ------------------------------user_dump_dest string /opt/app/oracle/product/admin/orcl/udump 6. Exit to the OS layer and move to the user_dump_dest directory. Trace file names aregenerated by oracle in the following format [instance_name]+[oracle generatednumber].trc, so use the timestamp to locate the last trace file generated. Open the file in atext editor and remove everything above the STARTUP NOMOUNT ..' statement. Alter the CREATE CONTROLFILE statement for the following uses:Rename DB in Archivelog mode: CREATE CONTROLFILE SET DATABASE "new_db_name" RESETLOGSARCHIVELOG

Rename DB in Non-Archivelog mode: CREATE CONTROLFILE SET DATABASE "new_db_name" NORESETLOGSNOARCHIVELOG

Reuse DB name in Archivelog mode: CREATE CONTROLFILE REUSE DATABASE "db_name" RESETLOGS ARCHIVELOG Reuse DB name in Non-Archivelog mode: CREATE CONTROLFILE REUSE DATABASE "db_name" NORESETLOGSNOARCHIVELOG 7. Edit the rest of this file to reference the correct locations of you log files, datafiles andtemp files.8. Move the trace file to an appropriate location and name to recreate_db.sql.9. Connect as SYS with SYSDBA privileges and shutdown the database in immediatemode: SQL> connect / as sysdbaConnected. SQL> shutdown immediate 10. Move the following files to there corresponding locations in updated recreate_db.sqlfile.DATAFILESLog filesNOTE: Do not move your old control files or temp files to the new location.11. Restore or copy the backup and the archived logs (if any) to the new machine.12. Move your INIT$ORACLE_SID.ORA file to its new location. Ensure your controlfile and archive destinations in INIT are set properly to the new locations.13. Connect to SQLPLUS on your new machine as SYS AS SYSDBA and runcreate_db.sql script as follows: SQL> @[directory_location]/create_db.sql 14. Change the global database name if you renamed your database as follows: SQL> ALTER DATABASE RENAME GLOBAL_NAME = new_db_name; 15. Perform full system backup and store in a safe location.NOTE: This new backup will be you starting point for recovery in the new databaselocation.You have completed database cloning procedure

You might also like