Wednesday 26 September 2007

Clone db using RMAN & Point in time

I have performed another successful test with this on 26 Sept 2007 (this time clone point in time), worked like a dream on a staging env. See word document for more detail.

Good links:
http://users.telenet.be/oraguy.be/make_a_clone_of_your_database_1.htm
http://www.oracle-base.com/articles/9i/DuplicateDatabaseUsingRMAN9i.php



##############
# niDB's note on Restore as Clone db.
#
# Basic steps, please see docs for more detail. Run the steps with care.
# DO prepare a test on your staging evn before running these command on Prod
#
# Tested success on 9i and 10g (Linux)
#
# [Source db]=NIDEV1, [Clone db]=NITST1,
##############


# Make sure all the backup files are available on the source db box.
# If offline or on tape copy them back and make sure Oracle user can read them.
##############


# On clone box, create password file
##############
cd $ORACLE_HOME/dbs
orapwd file=orapwNITST1 password=oracle entries=5


# In the source database box, add following to your TNSNAMES file.
##############
NITST1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbtst1.nidb)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = NITST1)
)
)



# In the clone database box, add following to your LISTENER file & reload.
##############
(SID_DESC =
(GLOBAL_DBNAME = NITST1)
(ORACLE_HOME = /opt/oracle/product/9.2.0)
(SID_NAME = NITST1)
)

$ lsnrctl reload



# Based on the source db, create pfile for Clone database (copy original database
# pfile and modify below).
##############
*.background_dump_dest='/u01/oracle/admin/NITST1/bdump'
*.core_dump_dest='/u01/oracle/admin/NITST1/cdump'
*.user_dump_dest='/u01/oracle/admin/NITST1/udump'

*.db_name='NITST1'
*.instance_name='NITST1'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=NITST1XDB)'

# Added following to pfile so we use pfile to change location:
*.DB_FILE_NAME_CONVERT=(/u01/oracle/oradata/NIDEV1, /u01/oracle/oradata/NITST1)
*.LOG_FILE_NAME_CONVERT=(/u01/oracle/oradata/NIDEV1, /u01/oracle/oradata/NITST1)


# Copy the RMAN backup files from source database to clone server.
# Kept the location of backup files identical to original database server.
# Start the clone database on nomount, make sure you exit:
##############
sqlplus /nolog
startup nomount
exit


# To duplicate to clone database, on Souce connect to Source, rman catalog & clone
# database
# Use following command to connect
##############
export ORACLE_SID=NIDEV1
export NLS_LANG=.UTF8
export NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'

$ rman target / catalog rman/rman@[SOURCE_RMAN] auxiliary sys/oracle@NITST1

RMAN> run {
set newname for datafile 1 to '/u02/oracle/oradata/NITST1/system01.dbf';
set newname for datafile 2 to '/u02/oracle/oradata/NITST1/undotbs01.dbf';
set newname for datafile 3 to '/u02/oracle/oradata/NITST1/sysaux01.dbf';
set newname for datafile 4 to '/u02/oracle/oradata/NITST1/users01.dbf';
set newname for datafile 5 to '/u02/oracle/oradata/NITST1/NITST1_APP_01.dbf';
set newname for datafile 6 to '/u01/oracle/oradata/NITST1/NITST1_INDEX_01.dbf';
set newname for datafile 7 to '/u01/oracle/oradata/NITST1/NITST1_LARGE_DATA_01.dbf';
set newname for datafile 8 to '/u01/oracle/oradata/NITST1/NITST1_tools_01.dbf';
set newname for tempfile 1 to '/u02/oracle/oradata/NITST1/temp01.dbf';
DUPLICATE TARGET DATABASE TO NITST1 UNTIL TIME 'Sep 14 2005 14:17:00'
LOGFILE
GROUP 1 ('/u01/oracle/oradata/NITST1/redo01.log') SIZE 50M,
GROUP 2 ('/u02/oracle/oradata/NITST1/redo02.log') SIZE 50M,
GROUP 3 ('/u03/oracle/oradata/NITST1/redo03.log') SIZE 50M;
}


# Shudown clone and startup clone with resetlogs options.
##############
startup mount;
alter database open resetlogs;

No comments: