1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
to clone a database on the same server, the procedure is as follows :
Login to the old database as a dba user, and create a control file trace using the command alter database backup controlfile to trace;.
Shutdown the old instance. Do not shutdown abort or immediate as these will require instance recovery.
Take a cold backup of the control files, datafiles, redo logs - if you want but not really required, initSID.ora file.
Create an environment on the new server to receive the various dumps files etc. Create users, directories, edit oratab, tnsnames.ora and listener.ora files as required.
Copy (via tape, ftp etc) the dump files, control files, redo, initSID.ora and the control file trace over to the new environment.
Edit the control file trace to :
Remove all the comments from the top and bottom of the script.
Remove the startup nomount and recover database commands from the script.
Change create controlfile reuse database "old_name" noresetlogs ... to create controlfile reuse set database "new_name" resetlogs ....
Change the paths and file names for the datafiles and logfiles to match the new locations.
Save the file with a meaningful name - controlfile.sql for example.
Edit the initSID.ora file to :
Change the db_name parameter to match the new name given in the controlfile.sql script created above.
Change the paths to the control file(s).
Change the paths to user_dump_dest, background_dump_dest and core_dump_dest locations as appropriate, also log_archive_dest if the database is in archive log mode.
On the new server, set $ORACLE_HOME and $ORACLE_SID as required.
If you changed the filenames in the control file script and/or the control file names in the initSID.ora file, now is a good time to rename the actual datafiles and/or control file to match.
Run svrmgrl and connect internal or / as sysdba according to the version of Oracle in use.
Startup nomount the instance and run the controlfile.sql script created above.
Alter database open resetlogs; will then open the database. If you didn't copy the redo files over, or if you changed their names in the control file script, then new files will be created for you.
Alter database rename global_name to SID.domain; is now required otherwise the database will have the same global name as the old one.
When cloning to the same server, keep the old instance closed until the new one has been started and opened. Then the old one can be started again. If you don't keep the old one closed, Oracle will complain about some other instance already being in use - the message is a bit obscure! I find the best order is :
close old
build new
close new
open old
open new
If you use the above method to copy to a differing server, then Oracle will complain about files not being suitable (or found) when you try to open the new database. Again, the message is a bit misleading. |
Partager