Thursday, July 22, 2010

HOW TO CLONE A DATABASE IN WINDOWS IN SAME SERVER:
************************************************************
Assume Old Database Name=ORCL and New Database Name=AUX
Follow the below 7 steps:
Step 1:Create a password file.
orapwd file=$ORACLE_HOME/database/orapwaux password=pwd entries=5
Connect to orcl database and create pfile
Step 2: Create pfile='path/initaux.ora from spfile;
Step 3:Edit the pfile according to the new database path for adump,bdump,cdump and udump. If its not already there create those directories and place the path in pfile.
and we need to change the db_name=AUX and we need to include two important parameters in new init file.
db_file_name_convert= ('C:\oracle\oradata\orcl','C:\auxdir\oradata\aux')
log_file_name_convert=('C:\oracle\oradata\orcl','C:\auxdir\oradata\aux')
Step 4:Add the tnsnames.ora and listener.ora file for the new database(aux).
Below is the example for tnsentry and listener entry.
aux=
(Description=
(Address=(protocol=TCP)(HOST=santhanamuthu.in.ibm.com)(port=1521)
(connect_data=
(server=dedicated)
(server_name=aux)
)
)
Listener entry
(SID_DESC=
(GLOBAL_DBNAME=AUX)
(ORACLE_HOME=C:\oracle\product\10.2.0\db_1)
(SID_NAME=aux)
)
)
Step 5: Now we need to stop and start the listener or we need to do reload.
lsnrctl stop
lsnrctl start
Step 6:Create a service in window, use the below command:
oradim -new -sid AUX -starmode m - pfile=C:\oracle\product\10.2.0\db_1\database\initaux.ora
Step 6:In RMAN prompt give the below commands.
rman>connect auxilary sys/pwd@aux
rman>connect target sys/pwd@orcl
rman>startup clone nomount force;
instance started
rman>duplicate target database to aux;
It will take some time depend on size of the source database and we can exit once completed.
rman>exit
Now cloned database is ready;
set the environment to new aux database
rman>connect target sys/pwd;
you will get the below message
Connected to target database : AUX (DBID=157465780900)
If we want we can verify the new cloned database now.. :)