Oracle 10g Database cloning

What is Database cloning?

Database cloning is nothing but creating a Identical copy of existing database.

There are so many reasons for cloning database.
1) Every company will have Production , testing and development database. Developers must not develop database in Production database right? Tester must not test reports or database whatever on Production database right? Why because it will effects on performance of production database.

2) If DBA want to change dbname or DBID of the database

3)Relocating an Oracle database to another machine.

4)Moving Oracle database to new Storage media.

etc...

There are three ways to clone database

1) Clod cloning
2) Hot cloning
3) RMAN cloning

Today i will show How clone database using Hot cloning. Cold cloning is very easier to clone by using OS commands. RMAN cloning will talk at time of RMAN concepts.

Database cloning using Hot Backups:

Hot database cloning is more suitable for databases which are running 24X7X365 type of databases and is done using the hot backup. For hot database cloning, database has to be in archivelog mode and there no need to shutdown the database.
You already now, how to take backup database hot. If not please check my previous post.


1) i)connect to database .
    ii) Check to which database you are connected.
   iii) Check archivelog status
  iv)  Create a table (for Example) and create log switch.




Database name is PROD.


Confirm that we created table and log switch



2) So, I have database called PROD, I want to clone PROD database to another database called TEST.
    So create necessary parameter file and directory.
 
   i) Go to ORACLE_HOME/dbs directory and create pfile called initTEST.ora
      and insert db_name and version as show in below picture.




Check Parameter file and create required directories


3) Put the Tablespaces in backup mode and copy all datafiles to $ORACLE_BASE/oradata/TEST Directory 


Copying is not possible without take tablespaces to hot. So bring them to hot and copy.



Databfiles are copied to $ORACLE_BASE/oradata/TEST Directory.

Go to Oracle then Issue the command end backup and then create one more switch.


4) Now control files. Make a backup control files to trace. How?
   Check below picture.


backup trace file of controlfile is created go to that location and edit it.

5) Start delete lines carefully until you find STARTUP NOMOUNT line, then make necessary changes and
    and make finally as shown in figure.

NOTE: You need to very careful here to make it. If single letter goes wrong your database will not clone.


You are almost done.

6) set Oracle environment as TEST and run the script as shown in picture


You have datafiles created. Now You have control file created.

7) Now exit from TEST Database and Log on to PROD Database then create couple switches.


Confirm: switches are created or not.


8) Now log on to TEST Database. Set switches source in TEST database and apply switches.



9) Apply all the switches as shown in figure.




10) After succesfull execution of log files, now open database with resetlogs. 



11) Now check in TEST database accounts table cloned or not? open another terminal log in to PROD database for crosschecking.


Now you are done with cloning..

If you got any error while cloning. Mail me I will reply back to with solutions

Will get back to you with new topic.

Thanks
Sagar.

















 






2 comments:

  1. i couldn't find ur mail id could u plez share ur id .so that i can connect with you

    ReplyDelete
  2. you can reach me at dba.sagar@yahoo.com

    ReplyDelete