Thursday, June 5, 2014

Copy / clone oracle database

Lets we have current database name ZA1

preprerequisite-
1. We need parameter file from old database or you can write your own
 create pfile='d:\ZA2.ora' from spfile;

2. Get the datafiles and logfiles path information, we can get the path of control file from pfile.
select name from v$datafile;
select member from v$logfile;

3. Take the backup of control file to trace
alter database backup controlfile to trace;

4. Need cold database backup
shu immediate;
Now copy all datafiles and log file to specific folder


-- Clone the database - cold cloning
1. Create new folder structure (for control file, data files), for easily understand you can get the required folder structure from *.ora file and backup of control fil.
2. Even more , change the path in *.ora file and backup of control file

3. Open cmd

set oracle_sid=ZA2

oradim -new -sid ZA2 -intpwd ZA2 -startmode m -pfile D:\ZA2.ora
(make sure that u have place the "ZA2.ora" file at path, it will contain the contents of ZA1.ora file having some related changes of database name and folder path.)

You might got this error
DIM-00014: Cannot open the Windows NT Service Control Manager.
solution open cmd with "run as administrator"

4. Open database at nomount state
C:\Windows\system32> sqlplus sys/ZA2 as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 9 15:35:48 2013

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to an idle instance.


SQL> startup nomount pfile='D:\ZA2.ora'

5.  At this stage we need to create control file after startup database at nomount state
   connect with sysdba user (before creation of control file and reuse of datafile , copy all the datafiles and redo log file)

Get the create control file script from trace file and change the Database name & files path, also change 'REUSE' needs to be changed to 'SET'.

 CREATE CONTROLFILE SET DATABASE "ZA2" RESETLOGS force LOGGING noARCHIVELOG
     MAXLOGFILES 16
     MAXLOGMEMBERS 3
     MAXDATAFILES 100
     MAXINSTANCES 8
     MAXLOGHISTORY 1
     LOGFILE
     GROUP 1 'D:\app\gurjeet\oradata\ZA2\REDO01.LOG' SIZE 50M,
     GROUP 2 'D:\app\gurjeet\oradata\ZA2\REDO02.LOG' SIZE 50M,
    GROUP 3 'D:\app\gurjeet\oradata\ZA2\REDO03.LOG' SIZE 50M
    DATAFILE
    'D:\app\gurjeet\oradata\ZA2\SYSTEM01.DBF',
    'D:\app\gurjeet\oradata\ZA2\SYSAUX01.DBF',
    'D:\app\gurjeet\oradata\ZA2\UNDOTBS01.DBF',
    'D:\app\gurjeet\oradata\ZA2\USERS01.DBF'
    CHARACTER SET AL32UTF8
/

6. Now Database went into mount state after creation of control file.

7. Open the database
 Alter database open resetlogs;



Related series of posts
ORA-01503: ORA-01161: ORA-01110:
backup controlfile to trace / generate script of control file
Recover database if it is in between crashed


for any modification / updation / suggestion mail at gurjeetkamboj@gmail.com or comment.


No comments:

Post a Comment

web stats