Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do you clone an oracle instance? Basically, I want to end up copying it from d:\oracle\oldname to d:\oracle\newname.

I'm working with Oracle 10.2.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Look into using the RMAN DUPLICATE command. I believe this was introduced in 9i, but is certainly available in 10g. It takes care of all of those steps that used to be necessary when cloning manually such as renaming datafiles, recreating control files, resetting database name, etc.

If you have a new directory structure for data and log files you can just permanently set the clone's startup parameters to convert these automatically to the new format/location by a string replacement specification. Cloning then becomes as simple as connecting to the target ("clone from"), aux ("clone to"), and RMAN catalog databases and issuing the RMAN command "DUPLICATE DATABASE to (myNewDBname)". You can also set the "until time" to bring the clone up to an earlier point in time.

Oracle 11g adds the ability to clone directly from a live database.

By the way, if you're not backing up with RMAN, then drop everything else and start doing this now!

share|improve this answer
    
+1, the better way for sure, I just am not up to speed on RMAN, at least as far as providing a solution here. –  DCookie Jul 25 '09 at 20:45
    
This is definitly the way to do it. If it causes you to learn more about RMAN, then thats a bonus. A limitation on 9i is that the RMAN files you use for the recovery have to have to be located at the same path as the source server. –  Cephas Jul 31 '09 at 12:16

I assume you want a different instance name on the clone ?,

In many ways the easiest way may well be to use RMAN or your backup and restore software to do the job for you.

I think it would be along the lines of:

  • Backup your database
  • Shutdown your database
  • Create a new database with the same SID as the original
  • Restore into the new database
  • export ORACLE_SID=newname
  • Change the pfile or spfile to reflect the new location of the control file
  • Generate a new password file orapwd file=orapw password=?? entries=5
  • Start the new database up
  • Start the old database up

This is pieced together from memory and having a quick google, its been about 2 years since I did any serious work with oracle so I would not expect the above to be correct but it may set you off in the right direction.

If you wanted the same instance on a different server I would recommend using NFS and a netapp and flexclones as they work wonderfully.

share|improve this answer
    
in Windows, you also want to run oradim.exe to create the windows Service for the new database –  Ofir Manor Jul 23 '09 at 14:04
    
Do you also need to edit the listener.ora ? download.oracle.com/docs/cd/B28359_01/network.111/b28317/… –  James Jul 23 '09 at 15:27
    
No edit of listener is necessary if it's configured at the default port. Oracle databases now dynamically register with the listener. –  DCookie Jul 24 '09 at 22:44

If you can get a cold or hot backup of your database:

  1. Copy cold/hot backup files to the new directory structure.
  2. Modify your init.ora file for the new instance.
  3. Issue STARTUP MOUNT logged on as sysdba user
  4. Run the following commands:

    conn / as sysdba

    STARTUP NOMOUNT CREATE CONTROLFILE REUSE SET DATABASE "NEWNAME" RESETLOGS NOARCHIVELOG MAXLOGFILES xx MAXLOGMEMBERS xx MAXDATAFILES xxx MAXINSTANCES xx MAXLOGHISTORY xxxx LOGFILE GROUP 1 'd:\oracle\NEWNAME\REDO01.LOG' SIZE XXM, --pick your redo log size
    GROUP 2 'd:\oracle\NEWNAME\REDO02.LOG' SIZE XXM,
    GROUP 3 'd:\oracle\NEWNAME\REDO03.LOG' SIZE XXM DATAFILE
    'd:\oracle\NEWNAME\SYSTEM.DBF',
    'd:\oracle\NEWNAME\undotbs.DBF',
    'd:\oracle\NEWNAME\USERS.DBF',
    'd:\oracle\NEWNAME\sysaux.DBF',
    'd:\oracle\NEWNAME\TOOLS.DBF' -- any other files in your database need to be renamed as well CHARACTER SET WE8ISO8859P1; -- adjust as necessary

    ALTER DATABASE OPEN RESETLOGS;

and you'll probably want to do something like this as well:

ALTER TABLESPACE TEMP ADD TEMPFILE 'd:\oracle\newname\temp.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 20M MAXSIZE UNLIMITED;

That should get you close...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.