Below are the are steps to clone a oracle database
Connect to target system and execute
sqlplus / as sysdba
alter database backup controlfile to trace;
Get file from /u01/oracle/admin/oldlsq/udump/xxxx.sql
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;
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;
Shutdown the target database
Copy all data files into the new directories on the new server.
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.
cp /u01/oradata/oldlsq/* newhost:/u01/oradata/newlsq
cp /u01/oradata/oldlsq/* newhost:/u01/oradata/newlsq
cp /u03/oradata/oldlsq/* newhost:/u03/oradata/newlsq
cp /u04/oradata/oldlsq/* newhost:/u04/oradata/newlsq
cp /u01/oradata/oldlsq/* newhost:/u01/oradata/newlsq
cp /u03/oradata/oldlsq/* newhost:/u03/oradata/newlsq
cp /u04/oradata/oldlsq/* newhost:/u04/oradata/newlsq
Copy and Edit the Control file – Using the output syntax from STEP 1, modify the controlfile creation script by changing the following:
Old:
Old:
CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS
New:
CREATE CONTROLFILE SET DATABASE "NEWLSQ" RESETLOGS
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;
# backups, or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;
Re-names of the data files names that have changed.
Old:
DATAFILE'/u01/oradata/oldlsq/system01.dbf',
'/u01/oradata/oldlsq/mydatabase.dbf'
'/u01/oradata/oldlsq/mydatabase.dbf'
New:
DATAFILE'/u01/oradata/newlsq/system01.dbf',
'/u01/oradata/newlsq/mydatabase.dbf'
'/u01/oradata/newlsq/mydatabase.dbf'
Create the bdump, udump and cdump ,adump,pfile,dpdump directories
Copy-over the old init.ora file
cp $DBA/admin/olslsq/pfile/*.ora newhost:/u01/oracle/admin/newlsq/pfile
Modify the init.ora with the new locations and db name
Run the modified control file script.
sqlplus / as sysdba
startup pfile=’loaction of your pfile’ nomount;
Run the modified script to create control file
@db_create_controlfile.sql
alter database mount;
alter database open resetlogs;
No comments:
Post a Comment