You are on page 1of 4

Cloning the Database on the same server with different directory structure:

1. Copy the PFILE.ORA TO THE NEW LOCATION.


2. CHANGE THE FOLLOWING PARAMETER IN THE PFILE.
DB_NAME=tmprms
DB_UNIQUE_NAME=tmprms
db_recovery_file_dest='/backup/temp_rmsprd/backup/rman_backup/RMSPRD'
control_files=('/backup/temp_rmsprd/TMPRMS/oradata/tmprms/control01.ctl','/ba
ckup/temp_rmsprd/TMPRMS/oradata/tmprms/control02.ctl')
audit_file_dest='/backup/temp_rmsprd/TMPRMS/admin/tmprms/adump'
compatible='11.2.0.0.0'
db_recovery_file_dest_size=10G
diagnostic_dest='/backup/temp_rmsprd/TMPRMS/admin/tmprms'
db_file_name_convert=('/data/oraret/oradata/rmsprd/','/backup/temp_rmsprd/TMP
RMS/oradata/tmprms/')
log_file_name_convert=('/data/oraret/oradata/rmsprd/','/backup/temp_rmsprd/TM
PRMS/oradata/tmprms/')
3. export ORACLE_SID=tmprms
e SID)

(in the window platform create sid and then set th

4. connect as sysdba sqlplus / as sysdba


5. rman auxiliary/
RMAN>run{
SET UNTIL TIME "to_date('2012-06-04:08:30:00','YYYY-MM-DD:HH24:MI:SS')";
DUPLICATE DATABASE TO tmprms
BACKUP LOCATION '/backup/temp_rmsprd/backup/rman_backup/RMSPRD'
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2. Refresh the Database or Cloning the Production to Test Database .
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. shutdown target database
export ORACLE_SID=TRG
export NLS_DATE_FORMAT="YYYY-MM-DD hh24:mi:ss"
sqlplus / as sysdba
shutdown immediate
2. delete data files, redo log files and control files from target data file loc
ation
cd datafile location
* remove datafiles log files and control files
3. copy current init.ora file of target database and create parameter file with
name of source database
cd $ORACLE_HOME/dbs
pwd
cp initTRG.ora initSRC.ora
4. make following changes in initSRC.ora
*.db_name='SRC'
5. set environment variables to reflect source database and start instance in no
mount mode
export ORACLE_SID=SRC

sqlplus / as sysdba
startup nomount pfile=$ORACLE_HOME/dbs/initSRC.ora
cd /pathtobackupdirectory
6. restore control file from backup location
rman target /
RMAN> restore controlfile from '/pathtobackupdirectory/controlfilebackup
';
RMAN> alter database mount;
7. catalog rman backupsets copied from source database
RMAN> catalog start with '/pathtobackupdirectory';
RMAN> list backup of archivelog all
Thrd Seq
Low SCN
Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- --------1
673
5965763558889 2012-05-11 08:28:12 5965763882022 2012-05-11
12:22:38
Suppose we have to restore till time 2012-05-01 08:28:12 we have to set
sequence 673 + 1;
create file for building rman command file
vi head
RUN
{
ALLOCATE CHANNEL d1 DEVICE TYPE disk;
vi tail
SET UNTIL SEQUENCE 674;
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
}
vi datafiles.sql
set head off pages 0 feed off echo off verify off
set lines 200
spool rename_datafiles.lst
select 'SET NEWNAME FOR DATAFILE ' || FILE# || ' TO ''' || '/u03/oradata
/&1/' || substr(name,instr(name,'/',-1)+1) || ''';' from v$datafile;
spool off
exit;
vi logfiles.sql
set head off pages 0 feed off echo off
spool rename_logfiles.lst
SELECT 'SQL "ALTER DATABASE RENAME FILE '''''|| MEMBER ||'''''' ||chr(1
0)||'to ''''' || member || '''''" ;' FROM V$LOGFILE;
exit
8. generate data file rename script
SQL> connect / as sysdba
SQL> @datafiles
rename_datafiles.lst file will be created
9. generate redo log file rename script
SQL> @logfiles.sql
(delete the space by :%s/ //g) by using this command
rename_logfiles.lst will be created. Change values accordingly on the 'to' fi

les
10.prepare RMAN restore and recover database script
cat head rename_datafiles.lst rename_logfiles.lst tail > recovery.rcv
11.connect to target database via rman and excute the recovey.rcv
rman target /
RMAN> @recovery.rcv
12.Open the database with RESETLOGS
SQL> alter database open resetlogs;
13.Temporary Tablespace Reconfiguration
Obtain the name of the current tempfiles
SQL>select name from v$tempfile;
NAME
------------------------------------------------------------------------------/u03/oradata/SRC/temp01.dbf
Drop the tempfile
ALTER DATABASE TEMPFILE '/u03/oradata/SRC/temp01.dbf' drop including datafile
s;
Add a new tempfile for the refreshed database in the appropriate locationSQL>ALTER TABLESPACE temp ADD TEMPFILE '/u03/oradata/TARGET/temp01.dbf' size
2G;
14.Change the database name using nid
SQL> shutdown immediate
SQL> startup mount
# nid target=sys dbname=TARGET
Provide the sys password when asked. If executed succesfully the database wil
l be shutdown.
# export ORACLE_SID=TARGET
# sqlplus sys as sysdba
SQL> startup mount
SQL> alter database open resetlogs
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++
1. copy initrmsprd.ora to /backup/tmp_rmsprd/initmprms.ora
2. change following parameters and report me if there are any other parameters r
elated to rmsprd or the production paths. Imp create all the new directories req
uired for the parameters below
db_name=tmprms
db_unique_name=tmprms
db_recovery_file_dest='/backup/temp_rmsprd/backup/rman_backup/RMSPRD'
control_files=("/backup/temp_rmsprd/TMPRMS/oradata/tmprms/control01.ctl", "/back
up/temp_rmsprd/TMPRMS/oradata/tmprms/control02.ctl")
audit_file_dest='/backup/temp_rmsprd/TMPRMS/admin/tmprms/adump'
compatible='11.2.0.0.0'
db_recovery_file_dest_size=10G
diagnostic_dest='/backup/temp_rmsprd/TMPRMS/admin/tmprms'
db_file_name_convert=('/data/oraret/oradata/rmsprd/' , '/backup/temp_rmsprd/TMPR
MS/oradata/tmprms/')
log_file_name_convert=('/data/oraret/oradata/rmsprd/' , '/backup/temp_rmsprd/TMP

RMS/oradata/tmprms/')
3. #export ORACLE_SID=tmprms
4. #sqlplus '/as sysdba'
SQL> startup nomount pfile='/backup/tmp_rmsprd/initmprms.ora';
5. rman auxiliary /
RMAN> run{
SET UNTIL TIME "to_date('2012-10-19:21:05:00','YYYY-MM-DD:HH24:MI:SS')";
DUPLICATE DATABASE TO tmprms
BACKUP LOCATION '/backup/temp_rmsprd/backup/rman_backup/RMSPRD/'
}

You might also like