Create Controlfile Noresetlogs: Reuse Database "Oldlsq"
Create Controlfile Noresetlogs: Reuse Database "Oldlsq"
Create Controlfile Noresetlogs: Reuse Database "Oldlsq"
developers a full-sized TEST and DEV instance by cloning the PROD instance into the
development server areas.
This Oracle clone procedure can be use to quickly migrate a system from one UNIX server to
another. It clones the Oracle database and this Oracle cloning procedures is often the fastest
way to copy a Oracle database.
STEP 1: On the old system, go into SQL*Plus, sign on as SYSDBA and issue: “alter
database backup controlfile to trace”. This will put the create database syntax in the trace file
directory. The trace keyword tells oracle to generate a script containing a create controlfile
command and store it in the trace directory identified in the user_dump_dest parameter of the
init.ora file. It will look something like this:
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 240
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 ('/u03/oradata/oldlsq/log1a.dbf',
'/u03/oradata/olslsq/log1b.dbf') SIZE 30M,
GROUP 2 ('/u04/oradata/oldlsq/log2a.dbf',
'/u04/oradata/oldlsq/log2b.dbf') SIZE 30M
DATAFILE
'/u01/oradata/oldlsq/system01.dbf',
'/u01/oradata/oldlsq/mydatabase.dbf'
;
# Recovery is required if any of the datafiles are restored
# backups, or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;
STEP 3: Copy all data files into the new directories on the new server. You may change the
file names if you want, but you must edit the controlfile to reflect the new data files names on
the new server.
rcp /u01/oradata/oldlsq/* newhost:/u01/oradata/newlsq
rcp /u01/oradata/oldlsq/* newhost:/u01/oradata/newlsq
rcp /u03/oradata/oldlsq/* newhost:/u03/oradata/newlsq
rcp /u04/oradata/oldlsq/* newhost:/u04/oradata/newlsq
STEP 4: Copy and Edit the Control file – Using the output syntax from STEP 1, modify the
controlfile creation script by changing the following:
Old:
New:
STEP 5: Remove the “recover database” and “alter database open” syntax
# Recovery is required if any of the datafiles are restored
# backups, or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;
Save as db_create_controlfile.sql.
Old:
DATAFILE
'/u01/oradata/oldlsq/system01.dbf',
'/u01/oradata/oldlsq/mydatabase.dbf'
New:
DATAFILE
'/u01/oradata/newlsq/system01.dbf',
'/u01/oradata/newlsq/mydatabase.dbf'
cd $DBA/admin
mkdir newlsq
cd newlsq
mkdir bdump
mkdir udump
mkdir cdump
mkdir pfile
@db_create_controlfile.sql
First you need to obtain a script that will create a copy of the existing control file. This is
usually carried out with the SVRMGRL utility using the following commands:
2. CONNECT INTERNAL
3. ALTER DATABASE BACKUP CONTROLFILE TO TRACE RESETLOGS;
This creates a file in the trace file directory. The file usually has the extension '.trc' and
will be located either in the directory defined by the parameter 'user_dump_dest', or if this
parameter is undefined it will be in $ORACLE_HOME/rdbms/log. Edit this file with your
favourite editor and remove the crud. Then rename it as "ctrl<NEW_SID>.sql," where
<NEW_SID> will be the ORACLE_SID of the copied database.
Where the string <OLD_SID> is the Oracle SID of the original database. This should be
changed to <NEW_SID>. Normallly this will be contained somewhere in the full filespec
(path + filename) of all redo logs, data logs and control files. If it isn't then it should have
been. This entire document assumes that you have the SID somewhere in the full
filespec of these crucial files and furthermore that there are no embedded spaces or other
weird characters in these filespecs. If you failed to observe these universal conventions
when you setup your database, you should not try to use any of the procedures outlined
in this document.
This will be a "cold" copy. So obviously you should make sure that the database is
shutdown and all services are stopped before attempting to "cold" copy the database.
If the copy is on the same host, you can use the DOS copy command (once the instance
is shutdown). If you are lack the manual dexterity required for a keyboard you can copy
the files with a mouse. If the target is a remote host then you will have to copy to a mass
storage device or copy across the network.
On the target host you need to copy all parameter files and all files mentioned above to
their new location. Make sure you preserve ownership and permissions. The copied
init<OLD_SID>.ora should be renamed to init<NEW_SID>.ora, and any parameter files
pointed to by an ifile parameter (e.g. parameter files such as config<OLD_SID>.ora)
should be renamed to contain <NEW_SID> (e.g. config<NEW_SID>.ora).
The datafiles and redo log files from the pervious step also need to be renamed to
contain the <NEW_SID> in the full filespec.
Now edit the file ctrl<NEW_SID>.sql and strip out everything up to and including the
STARTUP NOMOUNT command. Remove the ALTER DATABASE OPEN command and
everything after it. This leaves a command which just creates the controlfile.
Now change all the appropriate instances of <OLD_SID> to <NEW_SID>. Unless you
have a very good reason for doing so, you should make the database name the same as
<NEW_SID>. Save this script in an area where you will find it again.
Make sure that your ORACLE_SID is set to <NEW_SID>. Then use the SVRMGRL utility
to run the following commands:
29. STARTUP NOMOUNT
30. @ctrl<NEW_SID>
31. Create The Services For NEW_SID
Make sure that your current directory is the one that contains ctrl<NEW_SID>.sql