Home » Server Options » RAC & Failsafe » RMAN Duplicate DB for RAC?
RMAN Duplicate DB for RAC? [message #73063] Mon, 26 January 2004 20:30 Go to next message
Aditya Dhruva
Messages: 6
Registered: January 2004
Junior Member
Hi,

We have a script which uses the duplicate functionality of RMAN. It was designed for a standalone database. Now I need to make it work for a cluster DB (RAC installation).

1. Does RMAN support this?

2. Do I need to make separate executions for both the nodes of the cluster?

Any help in this regard is highly appreciated. We are currently blocked because we have no way of getting our system running without this!

******************************8

First attempt:

oracle@sf23> ./nsr_adv_duplicate_db.sh -d ADVFRW_sf25 -t ADVFRW1 -r RCAT -n sys -p sys ->

3808 11:52:49 ----- Starting Cloning Procedure -----

3808 11:52:50 INFO: Client host 'sf25' says, it is 'sf25'.

3808 11:52:51 Getting Original DB Name on the source host (referred by ADVFRW_sf25 TNS-name)...

...

3808 RMAN: GROUP 8 ( '/export/home/oracle/dev/ADVFRW/ADVFRW.redo181' ) SIZE 134217728 REUSE

3808 RMAN: DATAFILE

3808 RMAN: '/export/home/oracle/dev/ADVFRW/ADVFRW.system'

3808 RMAN: CHARACTER SET WE8ISO8859P1

3808 RMAN:

3808 RMAN: released channel: c1

3808 RMAN: released channel: auxt1

3808 RMAN: released channel: auxd1

3808 RMAN: RMAN-00571: ===========================================================

3808 RMAN: RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

3808 RMAN: RMAN-00571: ===========================================================

3808 RMAN: RMAN-03002: failure of Duplicate Db command at 01/21/2004 12:18:27

3808 RMAN: RMAN-06136: ORACLE error from auxiliary database: ORA-01503: CREATE CONTROLFILE failed

3808 RMAN: ORA-01504: database name 'ADVFRW1' does not match parameter db_name 'ADVFRW'

3808 RMAN: MAXLOGFILES 32

3808 RMAN: MAXLOGMEMBERS 2

3808 RMAN: MAXDATAFILES 255

3808 RMAN: MAXINSTANCES 4

3808 RMAN: MAXLOGHISTORY 452

3808 RMAN: LOGFILE

3808 RMAN: GROUP 1 ( '/export/home/oracle/dev/ADVFRW/ADVFRW.redo111' ) SIZE 134217728 REUSE,

3808 RMAN: GROUP 2 ( '/export/home/oracle/dev/ADVFRW/ADVFRW.redo121' ) SIZE 134217728 REUSE,

3808 RMAN: GROUP 3 ( '/export/home/oracle/dev/ADVFRW/ADVFRW.redo131' ) SIZE 134217728 REUSE,

3808 RMAN: GROUP 4 ( '/export/home/oracle/dev/ADVFRW/ADVFRW.redo141

3808 RMAN:

3808 RMAN: RMAN>

3808 RMAN:

3808 RMAN: Recovery Manager complete.

Second attempt:

oracle@sf23> ./nsr_adv_duplicate_db.sh -d ADVFRW_sf25 -t ADVFRW -r RCAT -n sys -p sys -c sf25 -s sf04 -g Srv_scl04-backup_DB_grp -l american_america.WE8ISO8859P1

5548 12:27:05 ----- Starting Cloning Procedure -----

5548 12:27:06 INFO: Client host 'sf25' says, it is 'sf25'.

5548 12:27:07 Getting Original DB Name on the source host (referred by ADVFRW_sf25 TNS-name)...

5548 12:27:07 Original DB is 'ADVFRW'

5548 12:27:08 INFO: BGROUP=Srv

5548 12:27:09 Fetching MASTERNODE...

5548 INFO: SOURCE_DB=ADVFRW_sf25

5548 INFO: CLONE_DB=ADVFRW

5548 INFO: RCNAME=RCAT

5548 INFO: CLIENT=sf25

5548 INFO: NSR_SERVER=sf04

5548 INFO: NSR_GROUP=Srv_scl04-backup_DB_grp

5548 INFO: NLS_LANG=american_america.WE8ISO8859P1

5548 INFO: UNTIL_TIME=

5548 INFO: DBUSER=sys

5548 12:27:09 ERROR: Parameter file '/export/home/oracle/products/9.2.0/dbs/initADVFRW.ora' not found.

Now we have contrary error messages. Target DB name ADVFRW does not work, because on the target nodes there are configuration files for the node specific DB names (ADVFRW1.ora on first node resp. ADVFRW2.ora on second node). But with the node specific DB name the script fails, because it does not match with the DB name of the source system.

****************************

Thanks in advance.

Warm regards,

-Aditya
Re: RMAN Duplicate DB for RAC? [message #73065 is a reply to message #73063] Tue, 27 January 2004 03:51 Go to previous messageGo to next message
Frank Naude
Messages: 4569
Registered: April 1998
Senior Member
Hi,

I'm not sure if this will work, but you can try to clone your RAC (or standalone DB) as a standalone non-RAC DB. When done, convert the duplicate DB to a RAC DB.

Best regards.

Frank
Re: RMAN Duplicate DB for RAC? [message #73066 is a reply to message #73063] Tue, 27 January 2004 04:12 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10694
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
1. RMAN does support this. I do this regularly in a weekly basis ( from RAC db to another RAC db, from RAC db to a single instance db).
2. RMAN behaves the same way in both single instance and clusterd RAC instance.
the difference is in the Database and not in RMAN
so, you have to a certain changes in the procedure u do the duplication.
PLEASE POST YOUR SCRIPT 

first
1. create the duplicate dummy database ( to startwith..) 
with dbca  and assign the raw partitions etc 
( it is easy to create datbase with dbca , create the layouts first , it will be easy later).

2. create a pfile from the spfile for DUP.
3. shutdown the clustered instances DUP1 AND DUP2 using SRVCTL ( Assuming a two node cluster. Else shutdown all instances in all nodes).
4. in any one of the node 
   export ORACLE_SID=DUP1.
   Startup NOMount the single DUP1 using initdup.ora 
   since the directory structure is different from the source database, 
   you have to rename the files ( it can be automated) to reflect the new locations.
5.  run the duplication steps . Now you are duplicating only one instance of the rac 
   ( since only one is up)
    this duplication by default will create only one
    thread of logfiles for the database (for the current instance DUP1).
   Manually create another thread for other instance.
   If there are more instances, create one thread
   for every instance.
   enable the thread
   duplication process will NOT DUPLICATE the temp file.
   so create a temp tablespace temp2 , alter database to use temp2 as default temp tablespace.
   rename the global_name to dup.abc.com

6.  By default archived logging will be turned ON.
    if you dont want it, turn it off manually.
    if everythin is ok with this single instance, proceed further.
    shutdown the single instance
    Startup single instance, recreate the spfile from pfile.
    Shutdown the single instance
8. Recreate the password file in other node(s)
9. Start the clustered instances using SRVCTL

Note:
1. Most of concepts told above depends on your RMAN configuration. 
2.  All the rules that apply for RMAN during a single instacne duplication will also apply here.
3. ONLY difference in RAC is,
   You duplicate a clustered RAC into a single Instance database and convert it into a RAC database.


Re: RMAN Duplicate DB for RAC? [message #73068 is a reply to message #73066] Tue, 27 January 2004 18:16 Go to previous messageGo to next message
Aditya Dhruva
Messages: 6
Registered: January 2004
Junior Member
Hi,

thanks for the very fast response!..Below is the script in question. Can you please let us know the modifications that are required in this script? Since we are from a different background, getting this script working is our only intention at the moment! :)

*******************************************

#!/bin/ksh
#-------------------------------------------------------------------------
# SCRIPT NAME: nsr_adv_duplicate_db.sh
#-------------------------------------------------------------------------
# SHORT DESCRIPTION: Duplicate a Database from Backup
# ENVIRONMENT:
# PARAMETERS: -d <DB> the TNS-Name to the Database to clone
# -t <DB> the name of the newly created (cloned) Database
# -r <DB> the TNS-name to the Recovery Catalog
# -n <DBUSER> database-user to connect to the original database
# -p <DBPASSWORD> password of the database-user
# { -c <HOST> the host, that has the original version of the DB
#
# -s <NETWORKER>, specifies the name of the Networker Server
# -g <GROUP>, specifies the Client's Group resource name
# -l <LANG>, NLS_LANG of the Database }
# [[ -u <TIME> A state specifier by time of the original DB to clone to that time
# if not used, cloning will be made to the latest available state in backup ]]
# RETURN VALUE: 0 if successful
# FUNCTIONS:
# NOTES: the script must be started under user oracle
#-------------------------------------------------------------------------
# HISTORY :
# VERS. NR | DATE | CHANGES &#124INIT.| NUMBER
# 1.0 | 09/26/02 | First Version | JK | CR0830
# 1.1 | 10/04/02 | minor changes | RK | CR0830
# 1.2 | 11/12/02 | NOFILENAMECHECK | RK | RK0000
# 1.3 | 11/12/02 | sqlplus connect as sysdba | RK | RK0000
# 1.4 | 11/26/02 | Remove 1.3 changes | SS | RC8211
#-------------------------------------------------------------------------

# Global settings
PATH=$PATH:/opt/nsr:/usr/ucb:/opt/SMAW/SMAWnw:$ORACLE_HOME/bin
CFG_FILES=/etc/nsradv
HOSTNAME=`uname -n`

#-------------------------------------------------------------
# FUNCTION NAME: write_log
#-------------------------------------------------------------
# SHORT DESCRIPTION: Write logs to the ${LOGFILE} logfile
# ENVIRONMENT: LOGFILE
# PARAMETERS: Message to write
# RETURN VALUE: 0 if operation succeeded
# NOTES:
#-------------------------------------------------------------
write_log()
{
echo $$ `date '+%H:%M:%S '`"$@" >> ${LOGFILE}
echo $$ `date '+%H:%M:%S '`"$@"
}
#-------------------------------------------------------------
# FUNCTION NAME: write_log_guard
#-------------------------------------------------------------
# SHORT DESCRIPTION: Write logs to the ${LOGFILE} logfile
# Don't write more than a specified number
# of lines
# ENVIRONMENT: LOGFILE
# PARAMETERS: $1 = max lines
# $2 = print string at the beginning of lines
# RETURN VALUE: 0 if operation succeeded
# 99 if too many lines
# 8 if RMAN error found
# NOTES:
#-------------------------------------------------------------
write_log_guard()
{
awk 'BEGIN { ERROR=0 }
{if (NR>'$1')
{ print "Interrupting the logging, too many number of lines ('$1')!" >> "'$LOGFILE'";
print "Interrupting the logging, too many number of lines ('$1')!" ;
exit 99; }
else
{ printf "'$$' '$2' %sn", $0 >> "'$LOGFILE'"
printf "'$$' '$2' %sn", $0; } }
/ERROR MESSAGE/ { ERROR=8 }
END { exit ERROR }'
}
#-------------------------------------------------------------
# FUNCTION NAME: usage
#-------------------------------------------------------------
# SHORT DESCRIPTION: print usage information
# ENVIRONMENT:
# PARAMETERS: none
# RETURN VALUE: none
# NOTES:
#-------------------------------------------------------------
usage()
{
echo "Duplicate DB"
echo "usage: nsr_adv_duplicate_db.sh -d <DB> -t <DB> -r <DB> -n <USER> -p <PASSWORD> { -c <DBHOST> &#124"
echo " -s <NSRHOST> -g <NSRGROUP> -l <NLSLANG> } [[ -u <TIME> ]]"
echo
echo "-d <DB> the TNS-Name of the source database to clone"
echo "-t <DB> the name of the newly created (cloned) Database"
echo "-r <DB> the TNS-name to the Recovery Catalog"
echo "-n <USER> database-user to connect to the original database"
echo "-p <PASSWORD> password of the database-user"
echo "-c <DBHOST> the host, that has the original version of the DB"
echo "-s <NSRHOST> Networker server"
echo "-g <NSRGROUP> specifies the Client's Group resource name, e.g. Srv_sunfi05a_DB_grp"
echo "-l <NLSLANG> NSR_LANG setting of the original database"
echo "-u <TIME> A state specifier by time of the original DB to clone to that time."
echo " if it not used, cloning will be made to the latest available state in backup."
}
#-------------------------------------------------------------
# FUNCTION NAME: set_missing_parameters
#-------------------------------------------------------------
# SHORT DESCRIPTION: sets some variables, values obtained from client host
# ENVIRONMENT:
# PARAMETERS: variable names to fill
# RETURN VALUE: none
# NOTES:
#-------------------------------------------------------------
set_missing_parameters()
{
MISSING=""
for var in "$@"
do
eval [[ -z "$$var" ]] && MISSING="$MISSING $var"
done

[[ -z "$MISSING" ]] && return 0

# checking remote access
ITS_NAME=`rsh $CLIENT uname -n 2>/dev/null`
if [[ $? -ne 0 ]]
then
write_log "ERROR: cannot login to client host '$CLIENT'."
write_log "ERROR: cannot fetch value for the variable(s): $MISSING"
write_log "exiting..."
return 1
fi

write_log "INFO: Client host '$CLIENT' says, it is '$ITS_NAME'."

FOUND=`rsh $CLIENT find ${CFG_FILES} 2>/dev/null`
echo "$FOUND" | grep "$CFG_FILES/.*/savedb.cfg$" > /dev/null
if [[ $? -ne 0 ]]
then
write_log "ERROR: there is no savedb.cfg on $CLIENT in $CFG_FILES."
return 1
fi
echo "$FOUND" | grep "$CFG_FILES/global.cfg$" > /dev/null
if [[ $? -ne 0 ]]
then
write_log "ERROR: file not found on $CLIENT: $CFG_FILES/global.cfg"
return 1
fi

write_log "Getting Original DB Name on the source host (referred by $SOURCE_DB TNS-name)..."
ORIG_DB=`echo "set linesize 32000
set pagesize 0
select value from v\$parameter where name='db_name';" |
sqlplus -s $DBUSER/$DBPASSWORD@$SOURCE_DB`

write_log "Original DB is '$ORIG_DB'"

# fetching config from client host
BGROUP=`rsh $CLIENT grep -l "^${ORIG_DB}.*" ${CFG_FILES}/*/savedb.cfg |
sed "s!^${CFG_FILES}/(.*)/savedb.cfg!1!"`

write_log "INFO: BGROUP=$BGROUP"

echo "$FOUND" | grep "$CFG_FILES/$BGROUP/env.cfg$" > /dev/null
if [[ $? -ne 0 ]]
then
write_log "ERROR: file not found on $CLIENT: $CFG_FILES/$BGROUP/env.cfg"
return 1
fi

CONFIGS=`rsh $CLIENT cat $CFG_FILES/global.cfg $CFG_FILES/$BGROUP/env.cfg $CFG_FILES/$BGROUP/savedb.cfg`

if [[ -z "$NSR_SERVER" ]]
then
write_log "Fetching NSR_SERVER..."
LINE=`echo "$CONFIGS" | grep 'NSR_SERVER'`
eval "$LINE"
fi

if [[ -z "$MASTERNODE" ]]
then
write_log "Fetching MASTERNODE..."
LINE=`echo "$CONFIGS" | grep 'MASTERNODE'`
eval "$LINE"
fi

if [[ -z "$NSR_GROUP" ]]
then
write_log "Setting NSR_GROUP..."
NSR_GROUP=${BGROUP}_${MASTERNODE}_DB_grp
fi

if [[ -z "$NLS_LANG" ]]
then
write_log "Fetching NLS_LANG..."
NLS_LANG=`echo "$CONFIGS" | grep "^$ORIG_DB " | awk '{print $4}'`
fi

return 0
}
#-------------------------------------------------------------
# FUNCTION NAME: enable_networker_access
#-------------------------------------------------------------
# SHORT DESCRIPTION: add this host to the "remote access" list of specified resource
# ENVIRONMENT: NSR_GROUP
# PARAMETERS: NSR_CLIENT: hostname of client (resource name) to modify
# NSR_GROUP: identifier attribute (whom Client have to be make up)
# RETURN VALUE: none
# NOTES:
#-------------------------------------------------------------
enable_networker_access()
{
CLT=$1
GRP=$2
write_log "Cheching this host (oracle@$HOSTNAME) in the remote access list"
write_log "of source DB NSR Client (CLT=$CLT,GRP=$GRP)..."

EXISTING_LIST=`nsradmin -s $NSR_SERVER -i - <<EOF
show remote access
. type: NSR client;
name: $CLT;
group: $GRP
print
EOF`

# trim networker message "Current query set"
EXISTING_LIST=`echo $EXISTING_LIST| sed 's/Current query set//g'`

if echo "$EXISTING_LIST" | grep "oracle@$HOSTNAME" > /dev/null
then
write_log "Already added, OK."
return 0
fi

write_log "Adding..."
NEW_ATTRIBUTE=`echo $EXISTING_LIST&#124sed "s/;/, oracle@$HOSTNAME;/"`
echo "$NEW_ATTRIBUTE"

# update DB_Client resource
nsradmin -s $NSR_SERVER -i - <<EOF
. type: NSR client;
name: $CLT;
group: $GRP
update type: NSR client;
$NEW_ATTRIBUTE
EOF

}
#-------------------------------------------------------------
# FUNCTION NAME: prepare_clone_db
#-------------------------------------------------------------
# SHORT DESCRIPTION: prepare the clone db before cloning
# ENVIRONMENT:
# PARAMETERS: none
# RETURN VALUE: none
# NOTES:
#-------------------------------------------------------------
prepare_clone_db()
{
write_log "Preparing the clone database: starting in nomount mode..."
sqlplus /NOLOG <<EOF 2>&1 | write_log_guard 5000 SQL:
connect / as sysdba;
shutdown abort;
startup nomount;
EOF
}
#-------------------------------------------------------------
# FUNCTION NAME: clone_db
#-------------------------------------------------------------
# SHORT DESCRIPTION: clone a database
# ENVIRONMENT:
# PARAMETERS: none
# RETURN VALUE: none
# NOTES:
#-------------------------------------------------------------
clone_db()
{
write_log "Starting Cloning Database..."

[[ -n "$UNTIL_TIME" ]] && UNTIL_CMD="set until time '$UNTIL_TIME';"

rman target $DBUSER/$DBPASSWORD@$SOURCE_DB
rcvcat rman/rman@$RCNAME
auxiliary / <<EOF 2>&1 | write_log_guard 10000 RMAN:
run {
$UNTIL_CMD
allocate channel c1 type 'SBT_TAPE'
parms 'ENV=(NSR_SERVER=${NSR_SERVER},
NSR_CLIENT=${MASTERNODE},
NSR_GROUP=${NSR_GROUP})';

allocate auxiliary channel auxt1 type 'SBT_TAPE'
parms 'ENV=(NSR_SERVER=${NSR_SERVER},
NSR_CLIENT=${MASTERNODE},
NSR_GROUP=${NSR_GROUP})';

allocate auxiliary channel auxd1 type DISK;

set command id to 'rman';
duplicate target database to $CLONE_DB NOFILENAMECHECK;
}
EOF
}

# MAIN

if [[ "oracle" != `id&#124sed 's/^[[^(]]*(([[^)]]*)).*$/1/'` ]]
then
echo "ERROR: this script must be run as user oracle."
exit 1
fi

if [[ $# -eq 0 ]]
then
usage
exit 1
fi

unset SOURCE_DB CLONE_DB RCNAME CLIENT NSR_SERVER NSR_GROUP NLS_LANG UNTIL_TIME DBUSER DBPASSWORD

while [[ $# -gt 0 ]]
do
case $1 in
-d) SOURCE_DB=$2; shift 2;;
-t) CLONE_DB=$2; shift 2;;
-r) RCNAME=$2; shift 2;;
-c) CLIENT=$2; shift 2;;
-s) NSR_SERVER=$2; shift 2;;
-g) NSR_GROUP=$2; shift 2;;
-l) NLS_LANG=$2; shift 2;;
-u) UNTIL_TIME=$2; shift 2;;
-n) DBUSER=$2; shift 2;;
-p) DBPASSWORD=$2; shift 2;;
*) usage; exit 1;;
esac
done

if [[ -z "$SOURCE_DB" -o -z "$CLONE_DB" -o -z "$RCNAME" -o -z "$DBUSER" -o -z "$DBPASSWORD" ]]
then
echo "ERROR: Missing mandatory parameter(s)"
usage
exit 1
fi

if [[ -z "$NSR_SERVER" -o -z "$NSR_GROUP" -o -z "$NLS_LANG" ]] && [[ -z "$CLIENT" ]]
then
echo "ERROR: Client host, where the original database located is not specified,"
echo "ERROR: but it is mandatory if one of the option missing: -s -g -l"
usage
exit 1
fi

LOGFILE=/tmp/clonedb_${CLONE_DB}.$$

write_log "----- Starting Cloning Procedure -----"

set_missing_parameters NSR_SERVER MASTERNODE NLS_LANG NSR_GROUP || exit 13

write_log_guard 200 INFO: <<EOF
SOURCE_DB=$SOURCE_DB
CLONE_DB=$CLONE_DB
RCNAME=$RCNAME
CLIENT=$CLIENT
NSR_SERVER=$NSR_SERVER
NSR_GROUP=$NSR_GROUP
NLS_LANG=$NLS_LANG
UNTIL_TIME=$UNTIL_TIME
DBUSER=$DBUSER
EOF

if [[ ! -f $ORACLE_HOME/dbs/init${CLONE_DB}.ora ]]
then
write_log "ERROR: Parameter file '$ORACLE_HOME/dbs/init${CLONE_DB}.ora' not found."
exit 2
fi

# add access for DB Client
enable_networker_access $MASTERNODE $NSR_GROUP

ORACLE_SID=$CLONE_DB
NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS'
export ORACLE_SID NLS_LANG NLS_DATE_FORMAT

prepare_clone_db

clone_db
*******************************************

Hoping for a quick response

Warm regards,
-Aditya
Re: RMAN Duplicate DB for RAC? [message #73069 is a reply to message #73068] Wed, 28 January 2004 03:55 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10694
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
the script is too confusing.
i prefere to use a simple rman script.
and to suggest the changes in the script, i need more info
1. are you using catalog database?
2. are you duplicating to another machine?
3. is that a full duplicate ( whole database) or partial( one or more specific schema/tablespaces)?

I can post a simple sample script, if required.

[Updated on: Tue, 19 February 2008 04:05]

Report message to a moderator

Re: RMAN Duplicate DB for RAC? [message #73071 is a reply to message #73069] Wed, 28 January 2004 18:12 Go to previous messageGo to next message
Aditya Dhruva
Messages: 6
Registered: January 2004
Junior Member
1. ??
2. Yes -> we need to duplicate to another machine
3. It is a full duplicate

If you can post the script it will be just great!

Thanks!
Re: RMAN Duplicate DB for RAC? [message #73072 is a reply to message #73071] Thu, 29 January 2004 03:00 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10694
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
there are two modes in which u can implement RMAN backup.
without using RMAN catalog
and
with RMAN catalog.
if u use a catalog u need a seperate database to hold RMAN information ( which is most recomended for complex backup/restore/duplication requirements and to make use of FULL functionalites of rman)
else
if you dont use an rman catalog, the information is save in the control file itself.
FIRST DECIDE ON THIS. Read docs for RMAN implementation
and
RMAN in RAC.
as i told before, it all depends on the need and environment of RMAN.
first define the requirements and env.

whatever it is , i always use a straightforward-simple-rman-script.
the script you are using is too confusing.

#####################consider this script############################################
	#!/usr/bin/bash
     1  export ORACLE_SID=clon1
     2  export ORACLE_BASE=/u01/app/oracle
     3  export ORACLE_HOME=/u01/app/oracle/product/9.2.0
     4  export NLS_DATE_FORMAT='MON DD YYYY HH24:MI:SS'
     5  export SERVER=`uname -n`
     6  echo "Please enter the time in the format - MON DD YYYY HH24:MI:SS
     7        For Example : AUG 20 2002 09:00:00
     8        Please enter the time: c"
     9
    10  read dat
    11  rman target sys/sys@test1 rcvcat rc/rc@rmandb <<EOF
    12  resync catalog;
    13  exit;
    14  EOF
    15  rman  msglog '/backup/rmanscr/logs/clone.log' <<EOF
    16  connect target sys/sys@test1
    17  connect catalog rc/rc@rmandb
    18  connect auxiliary  sys/sys
    19  run {
    20  allocate channel ch1 type disk;
    21  allocate channel ch2 type disk;
    22  allocate channel ch3 type disk;
    23  allocate channel ch4 type disk;
    24  allocate channel ch5 type disk;
    25  allocate channel ch6 type disk;
    26  ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK;
    27  ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
    28  ALLOCATE AUXILIARY CHANNEL aux3 DEVICE TYPE DISK;
    29  set until time "to_date('$dat','MON DD YYYY HH24:MI:SS')";
    30  @/backup/rmanscr/rename.lst
    31  duplicate target database to clon
    32  skip tablespace 'USERS','SNAP','INDX'
    33  PFILE = /backup/rmanscr/initclon.ora
    34  LOGFILE
    35    GROUP 1 ('/dev/vx/rdsk/dev/clone_redo1_1a')  SIZE 128M REUSE,
    36    GROUP 2 ('/dev/vx/rdsk/dev/clone_redo1_1b')  SIZE 128M REUSE;
    37  }
    38  exit;
    39  EOF
    40  sqlplus -s "sys/sys as sysdba" @convert_clon_rac.sql >> /backup/rmanscr/logs/clone.log
####################script ends here ###################################################
# environment
###############################################################
assumption:
	using oracle 9i enterprise edition for sunOS
        EVerything relating to RMAN configurations are already done.
	in this case , im duplicating to the same host.
           if duplicating to other host, make sure the /backup is available to other host.
	this case deals with POINT-IN-TIME duplication
	in this case SOURCE and DUPLICATE database are RAC databases.
	The most recent backup is already available.
	The duplicate database is shutdown and NOMOUNTED.
	THe required raw partions for duplicate database are already created ( like in source)
	And as-usual any of these operations should be run as OS user ORACLE.
databases
	clon -> to be clone RAC database with instances clon1 and clon2
	test -> source production database with instances clon1 and clon2
	rmandb -> rman catalog database
users:
        I have many production databases and many cloned databases( based on time. say
	freeze1 may have cloned NOV03data,freeze2 dec03data, freeze3 jan04data).
        to make my life simpler
	i use seperate users in rman to backup,to restore and to clone.
	so
	rc/rc = user used to clone TEST to CLON
	r_test/rman= user used to backup TEST
###############################################################
#what the above script does
###############################################################
lines 1-5    -> set the environment
	     set the ORACLE_SID=dup_sid
             set the date format *******important for rman*********
line 6      -> read the point-in-time to which the duplication should be done
         
lines 11-13 -> connect to catalog database  and resync the catalog

lines 15-18 -> connect to target database ( source database from which the backups are read and duplicated)
	       connect to rman catalog ( as the user assinged to duplicate test to clon	)
               connect to auxillary database ( the to-be duplicated database identified by ORACLE_SID in line 1
                    which is already startup nomounted using a pfile.        
lines 19-30 -> allocate the channels
               allocate the auxillary channels
               set until the time
               rename the files. (the datafiles are read from backup and recreated for the dup database.
                        now we have to manually rename those file to reflect the new location 
                        in the new database. This is can be automated.
                        for example 
				/prod/system1.dbf and /prod/data1.dbf are read from backup and renamed to
                                /dup/system1.dbf and /dup/data1.dbf
		this list of renamed files is run now.
line 31      -> start the duplication ( duplicate test to clon)   
line 32      -> specify the tablespaces u want to skip. u if want the whole database
                      remove this line
line 33-37   -> specify the pfile to be used and redologs to be created.
                      since the RAC is involved here, we need to created another thread, later manually ( line 40)
		      
line 40      -> these are contents of the script
                duplication will not restore temp tablespaces.so create them.
		bash-2.03$ cat convert_clon_rac.sql
		alter database add logfile thread 2 '/dev/vx/rdsk/dev/clone_redo2_2a' size 128 m reuse;
		alter database add logfile thread 2 '/dev/vx/rdsk/dev/clone_redo2_2b' size 128 m reuse;
		alter database enable thread 2;
		create temporary tablespace temp2  tempfile  '/dev/vx/rdsk/dev/clone_temp'
		        size 2048 M reuse
		        extent management local
		        uniform size 1m ;
		ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP2;
		drop tablespace temp including contents;
		alter database rename global_name to clon.xxxx.xxx.xxxx;
		exit;
###other scripts###############
we have completely auotmated this process.
there are 3 scripts that has to be run sequentially.
pre_duplication = bring down the clone datdabase  and startup in nomount stage 
		  create the rename.lst ( to rename the files)	
		  and do some other preparations for the duplication	
duplication     = the above duplication script
post_duplication= if cloning is successful and all are happy, u need to run this.
                  after duplication RC user will be looking into duplicated database.
                  we need to unregister RC from DUP and register it back to source database.
                  so that next time, your duplication works seamless!.
		  You also need to create a new passwordfile in all other nodes.
                  bring down the single instance
                  bring the clustered instance up and available using SRVCTL
		  recreate the pfile for next duplication etc...	

###this one such logfile created by the cloning process using the above script##########

Recovery Manager: Release 9.2.0.1.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

RMAN>
connected to target database: TEST (DBID=1797740141)

RMAN>
connected to recovery catalog database

RMAN>
connected to auxiliary database: clon (not mounted)

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13>
14> set newname for datafile 1 to '/dev/vx/rdsk/dev/clone_system';
15> set newname for datafile 2 to '/dev/vx/rdsk/dev/clone_undotbs1';
16> set newname for datafile 3 to '/dev/vx/rdsk/dev/clone_undotbs2';
17> **end-of-file**
18> 19> 20> 21> 22> 23> 24>
allocated channel: ch1
channel ch1: sid=23 devtype=DISK

allocated channel: ch2
channel ch2: sid=24 devtype=DISK

allocated channel: ch3
channel ch3: sid=25 devtype=DISK

allocated channel: ch4
channel ch4: sid=26 devtype=DISK

allocated channel: ch5
channel ch5: sid=27 devtype=DISK

allocated channel: ch6
channel ch6: sid=28 devtype=DISK

allocated channel: aux1
channel aux1: sid=20 devtype=DISK

allocated channel: aux2
channel aux2: sid=21 devtype=DISK

allocated channel: aux3
channel aux3: sid=22 devtype=DISK

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting Duplicate Db at JAN 22 2004 12:31:42
Datafile 4 skipped by request
Datafile 5 skipped by request
Datafile 6 skipped by request

printing stored script: Memory Script
{
   set until scn  15007297;
   set newname for datafile  1 to
 "/dev/vx/rdsk/dev/clone_system";
   set newname for datafile  2 to
 "/dev/vx/rdsk/dev/clone_undotbs1";
   set newname for datafile  3 to
 "/dev/vx/rdsk/dev/clone_undotbs2";
   restore
   check readonly
   clone database
   skip tablespace  USERS, SNAP, INDX   ;
}
executing script: Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at JAN 22 2004 12:31:43

channel aux1: starting datafile backupset restore
channel aux1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /dev/vx/rdsk/dev/clone_undotbs2
channel aux2: starting datafile backupset restore
channel aux2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /dev/vx/rdsk/dev/clone_system
channel aux3: starting datafile backupset restore
channel aux3: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /dev/vx/rdsk/dev/clone_undotbs1
channel aux1: restored backup piece 1
piece handle=/backup/test/disk6/rman_TEST_516109977_bpiece6.bak tag=TAG20040122T115255 params=NULL
channel aux1: restore complete
channel aux2: restored backup piece 1
piece handle=/backup/test/disk4/rman_TEST_516109976_bpiece4.bak tag=TAG20040122T115255 params=NULL
channel aux2: restore complete
channel aux3: restored backup piece 1
piece handle=/backup/test/disk5/rman_TEST_516109976_bpiece5.bak tag=TAG20040122T115255 params=NULL
channel aux3: restore complete
Finished restore at JAN 22 2004 12:32:48
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "clon" RESETLOGS ARCHIVELOG
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY     3635
 LOGFILE
  GROUP  1 ( '/dev/vx/rdsk/dev/clone_redo1_1a' ) SIZE  134217728  REUSE,
  GROUP  2 ( '/dev/vx/rdsk/dev/clone_redo1_1b' ) SIZE  134217728  REUSE
 DATAFILE
  '/dev/vx/rdsk/dev/clone_system'
 CHARACTER SET WE8ISO8859P1

printing stored script: Memory Script
{
   switch clone datafile all;
}
executing script: Memory Script

datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=516112372 filename=/dev/vx/rdsk/dev/clone_undotbs1
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=516112372 filename=/dev/vx/rdsk/dev/clone_undotbs2

printing stored script: Memory Script
{
   set until time  "to_date('JAN 22 2004 12:18:00','MON DD YYYY HH24:MI:SS')";
   recover
   clone database
    delete archivelog
   ;
}
executing script: Memory Script

executing command: SET until clause

Starting recover at JAN 22 2004 12:32:52
datafile 4 not processed because file is offline
datafile 5 not processed because file is offline
datafile 6 not processed because file is offline

starting media recovery

archive log thread 1 sequence 50 is already on disk as file /archive1/test_1_50.arc
archive log thread 2 sequence 53 is already on disk as file /archive1/test_2_53.arc
archive log thread 1 sequence 51 is already on disk as file /archive1/test_1_51.arc
archive log thread 2 sequence 54 is already on disk as file /archive1/test_2_54.arc
archive log filename=/archive1/test_1_50.arc thread=1 sequence=50
archive log filename=/archive1/test_2_53.arc thread=2 sequence=0
archive log filename=/archive1/test_1_51.arc thread=1 sequence=51
archive log filename=/archive1/test_2_54.arc thread=2 sequence=54
media recovery complete
Finished recover at JAN 22 2004 12:32:55

printing stored script: Memory Script
{
   shutdown clone;
   startup clone nomount pfile= '/backup/rmanscr/initclon.ora';
}
executing script: Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     202867632 bytes

Fixed Size                      730032 bytes
Variable Size                167772160 bytes
Database Buffers              33554432 bytes
Redo Buffers                    811008 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "clon" RESETLOGS ARCHIVELOG
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY     3635
 LOGFILE
  GROUP  1 ( '/dev/vx/rdsk/dev/clone_redo1_1a' ) SIZE  134217728  REUSE,
  GROUP  2 ( '/dev/vx/rdsk/dev/clone_redo1_1b' ) SIZE  134217728  REUSE
 DATAFILE
  '/dev/vx/rdsk/dev/clone_system'
 CHARACTER SET WE8ISO8859P1

printing stored script: Memory Script
{
   catalog clone datafilecopy  "/dev/vx/rdsk/dev/clone_undotbs1";
   catalog clone datafilecopy  "/dev/vx/rdsk/dev/clone_undotbs2";
   switch clone datafile all;
}
executing script: Memory Script

cataloged datafile copy
datafile copy filename=/dev/vx/rdsk/dev/clone_undotbs1 recid=1 stamp=516112393

cataloged datafile copy
datafile copy filename=/dev/vx/rdsk/dev/clone_undotbs2 recid=2 stamp=516112393

datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=516112393 filename=/dev/vx/rdsk/dev/clone_undotbs1
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=516112393 filename=/dev/vx/rdsk/dev/clone_undotbs2

printing stored script: Memory Script
{
   Alter clone database open resetlogs;
}
executing script: Memory Script

database opened

printing stored script: Memory Script
{
# drop offline and skipped tablespaces
sql clone "drop tablespace  USERS including contents";
# drop offline and skipped tablespaces
sql clone "drop tablespace  SNAP including contents";
# drop offline and skipped tablespaces
sql clone "drop tablespace  INDX including contents";
}
executing script: Memory Script

sql statement: drop tablespace  USERS including contents

sql statement: drop tablespace  SNAP including contents

sql statement: drop tablespace  INDX including contents
Finished Duplicate Db at JAN 22 2004 12:33:19
released channel: ch1
released channel: ch2
released channel: ch3
released channel: ch4
released channel: ch5
released channel: ch6

RMAN>

Recovery Manager complete.

Database altered.

Database altered.

Database altered.

Tablespace created.

Database altered.

Tablespace dropped.

Database altered.

Re: RMAN Duplicate DB for RAC? [message #73100 is a reply to message #73072] Mon, 02 February 2004 18:15 Go to previous messageGo to next message
Aditya Dhruva
Messages: 6
Registered: January 2004
Junior Member
Hi,

Some more questions here:
Our scenario is that we have to duplicate the the same database on a different machine. f.x., ADVFRW DB on host1 to ADVFRW DB on host2. Absolutely the same configuration and everything. In this context:

1. How will this script work if the target and source DBs have the same name, only host changes?
2. We dont need any renaming of files, right?
3. We dont have a catalog database, so I can omit the rman DB part, right?
4. We dont have to skip any tablespaces, so that line also can be omitted?

Please reply asap. Thanks.
Re: RMAN Duplicate DB for RAC? [message #73103 is a reply to message #73100] Tue, 03 February 2004 03:26 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10694
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
as i told before
1. Your backup slice or place where u have your RMAN
   backups should be available to the other node also
   like a local directory.
   if u have ur backups in /backup in host1
   and /backup should be available in host2 also
   u can nfsmount /backup to host2.
2. if the directory structures (in the os level)
   are not different , you dont need the files to 
   be renamed. 
   if there is a file in
   host1:>/u03/oradata/db/system1.dbf
   then there should be the directory strucutre
   in host2 like host1:>/u03/oradata/db/system1.dbf
   ( since in RAC you need a raw partition, precreate the raw partition.)
3. if dont have the catalog database,
   you must be using RMAN snapshot controlfile configuration.
   check the manuals to make sure how to work with that.
   The restoration process is same whehter u used a catlog or snapshot controlfile.
   But certain thingies need to be taken care of.
4. if you dont want to skip any tablespaces just omit the clause.   

again, 
RMAN configurations for backup/restore/duplications should be 
highly tested and done with extreme care.
But once these are done, it will behave like an angel.
Study the documentation.
Everything is given in great details there.

Re: RMAN Duplicate DB for RAC? [message #73104 is a reply to message #73100] Tue, 03 February 2004 03:43 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10694
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
certain areas of the script(that i posted before) are displayed wrong here ( this is html forum so does some
formatting by itself).
take care of that,
else
i will send a new one.
########this is used fro duplicating with catalog
rman  msglog '/backup/rmanscr/logs/duplicate_prod_freeze.log' << EOF
connect target sys/sys@lawp1
connect catalog c_freeze/rman@rmandb
connect auxiliary  sys/sys
....
.....
.....

#########this can be used for duplication without catalog######
rman  msglog '/backup/rmanscr/logs/duplicate_prod_freeze.log' << EOF
connect target sys/sys@lawp1 nocatalog 
connect auxiliary  sys/sys
....
.....
....
#######################test above in a test env..i have not tested these#####################

Re: RMAN Duplicate DB for RAC? [message #490649 is a reply to message #73104] Wed, 26 January 2011 06:02 Go to previous message
dbanukesh
Messages: 96
Registered: November 2008
Location: London
Member

Hi Mahesh,

Though this is very old post, i find it very useful. I have done many duplication before in sinlge instance databases using a backup tool and rman catalog. At the moment i was trying to do a RAC database duplication and facing some issues. For this i was doing a testing on my 1-node RAC. Primary and duplicated database is on the same Host and oracle version is 10.2.0.3. I perfomed following steps:

1.Created a DUPL database using DBCA.
2.Created a pfile using spfile.
3.Dropped all the datafiles, controlfiles and redo log files.
4.Started the database in nomount using pfile.
5.Disable cluster related parameters in pfile.
6.Took a full backup of the MAIN database with archivelog on disk.
6.Duplicate the database and it is done successfully.
7.Shutdown the instance and enabled cluster parameters.
8.Start instance using SRVCTL fails with error CRS-0215: Could not start resource 'ora.DUPL.DUPL1.inst'

But if start the instance using sqlplus it comes up nicely. There is not much information in alert log files. Can you please highlight what i am missing here?

Previous Topic: Migrating single node database to RAC
Next Topic: Need RAC meterials
Goto Forum:
  


Current Time: Fri Jun 18 06:58:49 CDT 2021