No great genius has ever existed without some touch of madness.

Monday 31 October 2011

Cloning using cold backup


1.   Identify and copy the database files

With the source database started, identify all of the database's files.

            Stop the source database with:
     
shutdown immediate

      Copy all system,sysaux,temp,log,users..etc to the desired location.
      Do not copy the control files across.



2.   Produce a pfile for the new database
             
             Start the source database up again
     
Startup

      From sqlplus:

create pfile='C:\...\init<new database sid>.ora' from spfile;
       
      Once created, the new pfile will need to be edited. If the cloned   
      database is to have a new name, this will need to be changed,
      as will any paths.


3.   Creating controlfile script


Create a control file for the new database with the source database
startup.
           From sqlplus:

 alter database backup controlfile to trace as 'c:\....\cr_<new
 sid>.sql' 

       The file will require extensive editing before it can be used.

  • Remove all lines from the top of the file up to but not including the second 'STARTUP MOUNT' line (it's roughly halfway down the file).
  • 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'
  • Move to the top of the file to the 'CREATE CONTROLFILE' line. The word 'REUSE' needs to be changed to 'SET'. The database name needs setting to the new database name (if it is being changed). Decide whether the database will be put into archivelog mode or not.
  • If the file paths are being changed, alter the file to reflect the changes.

Here is an example of how the file would look



6.  Specifying Instance Sid

D:\oracle\product\10.1.0\Db_1>oradim -new -sid %ORACLE_SID% -intpwd MYSECRETPASSWORD -startmode M

7.  Starting up the database

C:\....\...>set oracle_sid=<new_sid>

C:\....\...>sqlplus /nolog

SQL>connect  sys/sagar as sysdba

SQL>startup nomount

SQL>@C:\.....\....\....\cr_<new _sid>.sql
    The above will create a control file


8.  Open up your new database

SQL>alter database open;

Now,check up ur new cloned database whether it is like ur source databse or not. 

No comments:

Post a Comment