#!/bin/sh
#############################################################Pay Attention Please############################################################
###This script only tested on RHEL 3.0 for E-business Suite 11i. If you want to use it for E-business Suite R12, You have to Replace the ###
###path of start and stop scripts. Before running the script, make sure all variable has been changed according to your system!!!!!!!!!!!!###
###And because of it is designed to do clone from a backup through Physical Standby and Archivelogs, so you also need to create a Physical###
###Standby on your test server and write a scripts for your Physical Standby to: 1) sync the archive logs; 2) then switch to primary every###
###day; 3) before switchover you should backup the Physical Standby. You should also create a script to: 1) run prelclone on the source db###
###tier, 2) copy $ORACLE_HOME/appsutil/clone from the source db to the target. The last, you should create a backup after your first clone###
###for some files, such as /etc/oraInst.loc, pfile, $CONTEXT_NAME.xml, wdbsvr.app, CGIcmd.dat, etc........................................###
oruser=ortest
apuser=aptest
appspw=apps ###Apps password will be changed to this after refreshed###
apclpw=abcdefg ###Apps password of source database###
systpw=xyz ###System password of source database###
CONTEXT_NAME=TEST_testserver
ORACLE_HOME=/test/oracle/product/920
ORACLE_SID=TEST
export oruser apuser appspw apclpw systpw CONTEXT_NAME ORACLE_HOME ORACLE_SID
echo ""
echo "Shutting down services on Middle Tier ...please wait"
su - $apuser -c "\$COMMON_TOP/admin/scripts/\$CONTEXT_NAME/adstpall.sh apps/$appspw"
echo "Waiting for concurrent manager processes to exit..."
echo "Waiting for another 10 munite"
sleep 600
pkill -9 -u $apuser
echo ""
echo "Middle tier services shut down"
echo ""
echo "Shutting down database listener as $oruser user...please wait"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addlnctl.sh stop \$ORACLE_SID"
echo ""
echo "Shutting down database as $oruser user...please wait"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addbctl.sh stop abort"
echo ""
echo "All services shut down."
echo "Start to recover database."
cp --reply=yes /etc/oraInst.loc.db.$ORACLE_SID /etc/oraInst.loc
su - $oruser -c "sh \$HOME/rman_standby_recover.sh"
su - $oruser -c "sh \$HOME/auto_copy_clone.sh"
echo "Start to Clone database"
su - $oruser -c "cd $ORACLE_HOME/appsutil/clone/bin;perl adcfgclone.pl dbTier $ORACLE_HOME/appsutil/$CONTEXT_NAME.xml <<EOF
$apclpw
EOF
"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addbctl.sh stop immediate"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;cp --reply=yes \$ORACLE_HOME/dbs/init\$ORACLE_SID.ora.bck \$ORACLE_HOME/dbs/init\$ORACLE_SID.ora"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addbctl.sh start"
echo ""
echo "Start to Clone apps"
cp --reply=yes /etc/oraInst.loc.ap.$ORACLE_SID /etc/oraInst.loc
su - $apuser -c "cd \$COMMON_TOP/clone/bin;perl adcfgclone.pl appsTier \$HOME/\$CONTEXT_NAME.xml <<EOF
$apclpw
EOF
"
echo "waiting for application startup"
#############################################################Pay Attention Please############################################################
###This script only tested on RHEL 3.0 for E-business Suite 11i. If you want to use it for E-business Suite R12, You have to Replace the ###
###path of start and stop scripts. Before running the script, make sure all variable has been changed according to your system!!!!!!!!!!!!###
###And because of it is designed to do clone from a backup through Physical Standby and Archivelogs, so you also need to create a Physical###
###Standby on your test server and write a scripts for your Physical Standby to: 1) sync the archive logs; 2) then switch to primary every###
###day; 3) before switchover you should backup the Physical Standby. You should also create a script to: 1) run prelclone on the source db###
###tier, 2) copy $ORACLE_HOME/appsutil/clone from the source db to the target. The last, you should create a backup after your first clone###
###for some files, such as /etc/oraInst.loc, pfile, $CONTEXT_NAME.xml, wdbsvr.app, CGIcmd.dat, etc........................................###
oruser=ortest
apuser=aptest
appspw=apps ###Apps password will be changed to this after refreshed###
apclpw=abcdefg ###Apps password of source database###
systpw=xyz ###System password of source database###
CONTEXT_NAME=TEST_testserver
ORACLE_HOME=/test/oracle/product/920
ORACLE_SID=TEST
export oruser apuser appspw apclpw systpw CONTEXT_NAME ORACLE_HOME ORACLE_SID
echo ""
echo "Shutting down services on Middle Tier ...please wait"
su - $apuser -c "\$COMMON_TOP/admin/scripts/\$CONTEXT_NAME/adstpall.sh apps/$appspw"
echo "Waiting for concurrent manager processes to exit..."
echo "Waiting for another 10 munite"
sleep 600
pkill -9 -u $apuser
echo ""
echo "Middle tier services shut down"
echo ""
echo "Shutting down database listener as $oruser user...please wait"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addlnctl.sh stop \$ORACLE_SID"
echo ""
echo "Shutting down database as $oruser user...please wait"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addbctl.sh stop abort"
echo ""
echo "All services shut down."
echo "Start to recover database."
cp --reply=yes /etc/oraInst.loc.db.$ORACLE_SID /etc/oraInst.loc
su - $oruser -c "sh \$HOME/rman_standby_recover.sh"
su - $oruser -c "sh \$HOME/auto_copy_clone.sh"
echo "Start to Clone database"
su - $oruser -c "cd $ORACLE_HOME/appsutil/clone/bin;perl adcfgclone.pl dbTier $ORACLE_HOME/appsutil/$CONTEXT_NAME.xml <<EOF
$apclpw
EOF
"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addbctl.sh stop immediate"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;cp --reply=yes \$ORACLE_HOME/dbs/init\$ORACLE_SID.ora.bck \$ORACLE_HOME/dbs/init\$ORACLE_SID.ora"
su - $oruser -c ". $ORACLE_HOME/$CONTEXT_NAME.env;\$ORACLE_HOME/appsutil/scripts/\$CONTEXT_NAME/addbctl.sh start"
echo ""
echo "Start to Clone apps"
cp --reply=yes /etc/oraInst.loc.ap.$ORACLE_SID /etc/oraInst.loc
su - $apuser -c "cd \$COMMON_TOP/clone/bin;perl adcfgclone.pl appsTier \$HOME/\$CONTEXT_NAME.xml <<EOF
$apclpw
EOF
"
echo "waiting for application startup"
No comments:
Post a Comment