Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Hot Standby Script

RE: Hot Standby Script

From: Afanassiev, Alex <Alex.Afanassiev_at_team.telstra.com>
Date: Mon, 22 May 2000 16:14:36 +1000
Message-Id: <10504.106185@fatcity.com>


Hi David

The script below (Solaris 2.6 and Oracle 7.3.4) should be executed on the standby box. It copies the archive logs from the primary box using mirror utility (http://sunsite.org.uk/packages/mirror/) and applies the logs to the standby database.
The script calls dbenv.sh which just sets the Oracle env variables.

This is an example only. HTH.

#!/bin/ksh
#

JOB=`basename $0`
MIRROR=/usr/local/mirror/mirror
TOOLS=/ora/admin/maint
TOOLSLOG=$[TOOLS}/LOGS
ARCHIVEDIR=/ora/archive
PRIME_HOST="<prime host>"
SUCCESS=0
WARNING=1
#
# validate parameters
#

ERRMSG="
   $JOB: invalid parameter:
   $JOB <dbname>"
if [ $1 ]; then

   DBNAME=$1
else

   echo $ERRMSG
   exit ${ERROR}
fi
# copy the logs from the prime server

$MIRROR -p oraarchive
RET=$?
case ${RET} in

   $SUCCESS)

       echo "$JOB: Completed successfully"
       break;;
   *)
       echo "$JOB: ERROR: Failed to replicate files "
       echo "$JOB:        in /ora/archive directory"
       break;;

esac
# now apply archive logs to the STANDBY database
# even if failed to copy, there are still could be
# archive logs (from the previous ftp) that are applicable
# check if the instance already running
# set oracle environment variables

. ${TOOLS}/dbenv.sh $DBNAME y
#

if [ $? -ne 0 -o `ps -fu oracle |grep ora_ | \ grep ${ORACLE_SID} | wc -l` -eq 0 ]; then

   # startup instance nomount and mount as standby database    # and recover from all available archive logs    echo "$JOB: Starting up the instance and "    echo "$JOB: mounting ${ORACLE_SID} as a standby database"    $ORACLE_HOME/bin/svrmgrl << EOF

       connect internal
       startup nomount pfile=$ORACLE_HOME/dbs/init${ORACLE_SID}.ora       
       alter database mount standby database;
EOF
   if [ $? -ne 0 -o `ps -fu oracle |grep ora_ | \ grep ${ORACLE_SID} | wc -l` -eq 0 ]; then
      echo "${JOB}: Failed to startup the instance... "
      exit ${ERROR}

   fi
fi
# set auto recovery on and recover from all available archive logs
echo "$JOB: Applying archive logs..."
$ORACLE_HOME/bin/svrmgrl << EOF

    connect internal
    set autorecovery on
    recover standby database;
EOF
# check if completed successfully

if [ $? -ne 0 ]; then

   echo "${JOB}: Failed to apply archive logs ... "    exit ${ERROR}
else

   echo "${JOB}: Succesfully applied archive logs..." fi
#

exit ${SUCCESS}

With regards
Alex Afanassiev
Oracle DBA, TOC Operations Support/IDO

Tel:	(03) 8 661 20 61
Fax:	(03) 9 650 36 74


> -----Original Message-----
> From:	David Turner [SMTP:dturner_at_linuxcare.com]
> Sent:	Saturday, May 20, 2000 6:01 AM
> To:	Multiple recipients of list ORACLE-L
> Subject:	Hot Standby Script
> 
> Anyone have a script that applies the logs periodically to a standby 
> database? I am looking for a script that copies the new logs to the 
> standby host and applies those logs to the standby database. I don't 
> have the managed standby database option. 
>   
> 
> Thanks, Dave Turner 
> --
> Dave Turner, Senior Database Administrator, Linuxcare, Inc.
> 913.383.3052 tel, 913.579.3803 cel, 877.443.9553 pager > dturner@linuxcare.com, <http://www.linuxcare.com/> Received on Mon May 22 2000 - 01:14:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US