Sunday, January 4, 2009

Online Cloning in 9I

ONLINE CLONING IN 9i



Creating the Structure : 2


Taking Hot backup : 2

Editing The Script: 3

Create Environment File: 6

Create an environment file in the $HOME as clone.env. The following 6

Procedure to Clone the database: 6
Open the database in nomount state and run the clone.sql script. 6
Then recover the database using until cancel 7
Then apply necessary archive logs. 7
Open the database using 7






Prepared By,
N. Mounika

G.Santhosh Reddy











Online Cloning in 9i



Creating the Structure :

1. First we need to create the structure of the database i.e creating directories in the admin and oradata directories .
$export ORACLE_BASE=/d01/mt/ora9i
$mkdir –m 777 $ORACLE_BASEoradata/clone
$mkdir –m 777 $ORACLE_BASE/admin/clone/udump
$mkdir –m 777 $ORACLE_BASE/admin/clone/bdump
$mkdir –m 777 $ORACLE_BASE/admin/clone/cdump

Taking Hot backup :

2. Now ,take the hot backup of the production database by putting each tablespace in the backup mode and copy the datafiles to the $ORACLE_BASE/oradata/clone directory

sql> alter tablespace < tablespace name> begin backup;

Copy the corresponding datafile to the $ORACLE_BASE/oradata/clone
$cp ORACLE_BASE/oradata/ora9i/.dbf $ORACLE_BASE/oradata/clone.

3. After copying the datafile, we need to end the backup mode of the corresponding tablespace

sql> alter tablespace end backup;
4. Then archive the current online redo log
sql> alter system archive log current;

Repeat above steps for all tablespaces in the production database.

5. Also take backup of the production database control file using

sql>alter database backup controlfile to trace;
It generates script to recreate the control files. The default Destination location is indicated by the parameter user_dump_dest in PFILE or SPFILE

Editing The Script:

6. Open the Script and edit the changes and save it as clone.sql.
The script contains

CREATE CONTROLFILE SET DATABASE "clone” RESETLOGS ARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 50
MAXLOGMEMBERS 5E
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226

LOGFILE
GROUP 1 '/d01/mt/ora9i/oradata/clone/redo01.log' SIZE 100M,
GROUP 2 '/d01/mt/ora9i/oradata/clone/redo02.log' SIZE 100M,
GROUP 3 '/d01/mt/ora9i/oradata/clone/redo03.log' SIZE 100M
--STANDBY LOGFILE
DATAFILE
'/d01/mt/ora9i/oradata/clone/system01.dbf',
'/d01/mt/ora9i/oradata/clone/undotbs01.dbf',
'/d01/mt/ora9i/oradata/clone/cwmlite01.dbf',
'/d01/mt/ora9i/oradata/clone/drsys01.dbf',
'/d01/mt/ora9i/oradata/clone/example01.dbf',
'/d01/mt/ora9i/oradata/clone/indx01.dbf',
'/d01/mt/ora9i/oradata/clone/odm01.dbf',
'/d01/mt/ora9i/oradata/clone/tools01.dbf',
'/d01/mt/ora9i/oradata/clone/users01.dbf',
'/d01/mt/ora9i/oradata/clone/xdb01.dbf'
CHARACTER SET AL32UTF8
;

And save in the $HOME as clone.sql.


Create Environment File:
7 . Create an environment file in the $HOME as clone.env. The following
are the environment variables in clone.env

Export ORACLE_BASE=/d01/mt/ora9i
Export ORACLE_HOME=$OARCLE_BASE/9.0.2.4
Export ORACLE_SID=clone
Export LD_LIBRARY_PATH=$OARCLE_HOME/lib
Export LD_ASSUME_KERNEL=2.4.19
Export PATH=$ORACLE_HOME/bin:$PATH

Procedure to Clone the database:
8) First, Run the clone.env enivornment file.
$ . clone.env.
9) Open the database in nomount state and run the clone.sql script.
(In order to create the control file we have to startup the database in nomount state)



$sqlplus ‘/as sysdba’
Sql> stratup nomount
Sql> @clone.sql

Control file created.

10) Then try to open the database using
Alter database open resetlogs;
It show error message like
ORA-01195: online backup of file 1 needs more recovery to be
Consistent
ORA-01110: data file 1:’/d01mt/ora9i/oradata/clone/system01.dbf
11) Then recover the database using until cancel
sql>recover database until cancel using backup controlfile;
Then apply necessary archive logs.
12) Open the database using
sql > alter database open resetlogs

No comments:

Post a Comment