Nethence Pbraun Lab Webmail Your IP BBDock
print | donate | html/css | terms of use
Home | Unix | Windows | Oracle | Obsolete | Hardware | DIY | Mechanics | Scripts | Configs | Private

Oracle RMAN -- Clone a database
Duplicate from scratch in brief
- prepare the directories
- get and adapt the pfile
- switch redo logs and backup archivelogs
- share the backuppieces
- clone the database
- switch to spfile
- clean up
Duplicate update in brief
- shut down the database
- check spfile is there
- start nomount, create a pfile, shutdown the database
- add _convert statements to the pfile
- start nomount
- duplicate target
- switch to spfile
- eventually disable archivelogs
Prepare the directories
As root, eventually prepare /usr/local/oracle for redundant controlfile and redo logs,
mkdir /usr/local/oracle
chown oracle:oinstall /usr/local/oracle
chmod 750 /usr/local/oracle
As oracle, prepare the directories,
export ORACLE_SID=dbname2

cd $ORACLE_BASE/admin
chmod 750 $ORACLE_SID
mkdir adump dpdump pfile scripts
#mkdir bdump cdump udump
chmod 750 *

cd /u02/oradata
chmod 750 $ORACLE_SID

cd /usr/local/oracle
chmod 750 $ORACLE_SID
Get and adapt the pfile
On srv1, make a pfile,
. oraenv
sqlplus / as sysdba
create pfile from spfile;
and send it to srv2,
scp initdbname.ora srv2:~/
#rm -f initdbname.ora
On srv2, rename the pfile accordingly,
cd ~/
mv initdbname.ora $ORACLE_HOME/dbs/initdbname2.ora
edit the pfile,
cp initdbname2.ora initdbname2.ora.dist
vi initdbname2.ora
then :
- remove the first lines
- :%s/dbname/dbname2/g
(-) :%s/\/pathonsrv1/\/pathonsrv2/g
- define the path conversions,
Generate the orapw file to authenticate as sys without even having any controlfile nor datafile,
orapwd file=orapwdbname2 password=PASSWORD entries=10
note. entries means how many simultanate sys sessions are autorized.
fix perms,
chmod 640 orapwdbname2
Oratab, listener and tnsnames for both
Edit listener,
cd $ORACLE_HOME/network/admin
vi listener.ora
add into SID_LIST,
(GLOBAL_DBNAME = dbname2)
(ORACLE_HOME = /u01/product/10.2.0/ora1020)
(SID_NAME = dbname2)
lsnrctl stop
lsnrctl start

Edit tnsnames,
vi tnsnames.ora
dbname2 =
(SERVICE_NAME = dbname2)

dbname =
(SERVICE_NAME = dbname)
Add dbname2 to the oratab,
vi /etc/oratab
Switch redo logs and backup archivelogs
On srv1, switch the redo logs,
. oraenv
sqlplus / as sysdba
alter system switch logfile;
and backup the archivelogs,
_backup incr
Share the backuppieces
Make sure the backup dir is also available on srv2, either by NFS, or just copy the backuppieces.
Clone the database
Start dbname2 nomount (with the _convert pfile),
cd ~/
. oraenv
sqlplus / as sysdba
startup nomount
Make sure you got access to those databases through TNS,
- dbname on srv1 through srv2 TNS
- dbname2 on srv2 itself
- rcat on srv2 itself
rman target sys/PASSWORD@dbname catalog cat/CATPASSWD@rcat auxiliary sys/PASSWORD@dbname2
duplicate target database to dbname2;
note. disconnect from your previous sql prompt on ORCLDEV, otherwise the rman duplicate process will be waiting.
note. carefull here, startup/shutdown applies on the target, not the auxillary
note. eventually add this to the rman command to debug,
#rman ... debug trace rman.trc log rman.log
and watch what's going on in the dbname2 alert log,
tail -F /u01/admin/dbname2/bdump/alert_dbname2.log
Once finished, check everything is fine on dbname2,
. oraenv
sqlplus / as sysdba
select instance_name, host_name, startup_time, status
from v$instance;
also as user through TNS,
sqlplus USERNAME/PASSWORD@dbname2
select * from table1;
Switch to spfile
As sys, switch to spfile,
create spfile from pfile;
shutdown immediate
eventually remove the pfile,
rm initdbname2.ora
and start the database with the spfile,
Now that the clone is built, we no longer need the file_name_convert settings,
alter system reset db_file_name_convert scope=spfile sid='*'
alter system reset log_file_name_convert scope=spfile sid='*'
and eventually disable archivelogs,
  archive log list
shutdown immediate
startup mount
alter database noarchivelog;
alter database open;
Finish up
Eventually remove the TNS entry for the target database (dbname),
cd $ORACLE_HOME/network/admin
vi tnsnames.ora
Metalink 228257.1

Last update: Jun 28, 2010
Copyright © 2007-2015 Pierre-Philipp Braun