Cloning

Cloning Using Hot Backup

Cloning using hot backup

Cloning means copying all the data files, control files. Cloning can be done in 3 ways. 1) Using cold backup, 2) Using hot backup and 3) Using RMAN. Here we will see using Hot backup.

Here we have a database called TEST which is located in /u03/app/oracle/TEST/ and we are cloning this TEST database to CLONEH database which we will create it at the location /u04/app/oracle/CLONEH/

STEP 1: First we will copy all the s/w files from /u03/app/oracle/TEST/ to /u04/app/oracle/CLONEH/. If u doesn’t have CLONE H database directories created, we need to create them first.

[/u03/app/oracle/TEST/]$ cp –R * /u04/app/oracle/CLONEH/

STEP 2: Change the following folder structures.

a) Change /admin/TEST to /admin/CLONEH

b) Change /cfgtools/dbcr/TEST to /cfgtools/dbcr/CLONEH

c) Go to /dbs/initTEST.ora and change the parameters and rename that file to /dbs/initCLONEH.ora

1) U03 -> u04

2) TEST -> CLONEH

STEP 3: Login to the SQL*PLUS of the TEST database.

a) [] $ . oraenv

b) [] $ TEST

c) [] $ Sqlplus “ / as sysdba”

d) Startup mount;

e) Alter database open;

STEP 4: Test whether the archive logs are enabled or not? We must do the hotback in archive log enabled mode only. So first check whether they are enabled or not. This can be done using the command

[]$ archive log list.


If the archive log is not enabled the use the command
[] $ alter database archive log;

STEP 5: Use this sql command to check to find whether all the table spaced are in online mode or not.

[] $ select tablespace_name, online_status from dba_data_files;

STEP 6: Use the following command to startup the actual database backup using hotbackup.

[] $ select ‘alter database ‘ || ‘ tablespace_name || ‘ begin backup;’

From dba_tablespaces;
Where tablespace_name not like ‘TEMP%’;

STEP 7: The above command will give some result. Copy and paste the result over ths SQL PROMPT. It will starts the actual backup procedure.

STEP 8: In other window do copy the *.dbf files from TEST database which are located in /u03/app/oradata/TEST/*.dbf to the destination’s CLONEH oradata folder which is located at /u04/app/oradata/CLONEH/

STEP 9: Use the following command to end the actual database backup.

[]$ select ‘alter database ‘ || tablespace_name || ‘ end backup;’

From dba_tablespaces;

Where tablespace_name not like ‘TEMP%’;

STEP 10: This will create a control file back to trace. Normally the trace folder will be /u02/app/oracle/TEST/admin/TEST/udump.

SQL> alter database backup controlfile to trace;

STEP 11: Copy the last file (which is just created) in udump directory to /u04/app/oradata/CLONEH/ctrl.txt.

STEP 12: Open this ctrl.txt file and delete some line and CHANGE “REUSE” to SET and “NORESETLOGS” to RESETLOGS.

Sample script: (paste this script in ctrl.txt file and change the database name CLONEH to any other and change the path settings also.

CREATE CONTROLFILE SET DATABASE "CLONEH" RESETLOGS NOARCHIVELOG

MAXLOGFILES 5

MAXLOGMEMBERS 5

MAXDATAFILES 100

MAXINSTANCES 1

MAXLOGHISTORY 292

LOGFILE

GROUP 1 '/u04/app/oradata/CLONEH/redo01.log' SIZE 100M,

GROUP 2 '/u04/app/oradata/CLONEH/redo02.log' SIZE 100M,

GROUP 3 '/u04/app/oradata/CLONEH/redo03.log' SIZE 100M

-- STANDBY LOGFILE

DATAFILE

'/u04/app/oradata/CLONEH/system01.dbf',

'/u04/app/oradata/CLONEH/UNDOTBS01.dbf',

'/u04/app/oradata/CLONEH/sysaux01.dbf'

CHARACTER SET US7ASCII

;

STEP 13: Now we have created the initCLONEH.ora, so we can startup the CLONEH database in “nomount” stage.

[] $ . oraenv

[] $ CLONEH

[] $ sqlplus “ / as sysdba”

[] $ startup nomount;

[] $ @/u04/app/oradata/CLONEH/ctrl.ctl

[] $ alter database open resetlogs;

It will give error.

STEP 14: In TEST database at sql prompt we need to give the following command to get the current archive log file.

SQL> alter database open resetlogs;

STEP15: In CLONEH database at sql prompt give these

SQL> alter database open resetlogs;

It will give error.

SQL> recover database using backup controlfile until cancel;

It will ask for archive log files. The current archive log file will be stored at /u03/app/oracle/TEST/flash_recovery_area/DEV/archivelog/2007_09_07/filename.trc. So we need to specify this location.

After that it will ask for next sequence number, If we don’t have just give “CANCEL

STEP16: Then it will show “media recovery is cancelled”. If we get this error that means we are succeeded.

STEP17: In CLONEH

SQL> alter dabase open resetlogs;

STEP 18: Checking:

SQL> select name from v$database;

SQL> select name from v$datafile where name like ‘%MISS%’;
SQL> select name from v$datafile;
SQL> select name from v$tempfile;

SQL>select number from v$logfile;

No comments: