#!/bin/sh trap 'exit' 1 2 3 ################################################################################ # Script um ORACLE RDBMS beim System-Boot und nach dem Backup zu starten # # Nur auf dem Root-Server wird das RDBMS und der SQL*NET TCP/IP Server # gestartet. Die Discless-Nodes kontrollieren ob die Datenbanken in # /etc/oratab verfuegbar sind # # Das Script muss als Benutzer "oracle" gestartet werden ! # su oracle -c startoracle # # Martin Zahn 6.7.92 # ################################################################################ export ORACLE_HOME ORACLE_SID PATH # Determine what kind of system this is (standalone, cluster server or client) set_state() { if [ -x /bin/getcontext ] && set -- `getcontext` && cnodename=$1 && [ "$cnodename" != standalone ] then cnodes -s || /etc/cluster SYSTEM_NAME=$cnodename rootname=`cnodes -r` if [ ! "$rootname" ] then state=standalone elif [ "$SYSTEM_NAME" = "$rootname" ] then state=localroot else state=remoteroot fi else state=standalone fi } ORATAB=/etc/oratab # Check machine type (Root-Server, Discless, Standalone) set_state # Are Databases installed ? if [ ! -f $ORATAB ] then exit 1 fi # Set PATH if not set case $PATH in "") PATH=/bin:/usr/bin:/usr/ucb:/usr/5bin:/etc ;; esac # # Loop for every entry in ORATAB file and and try to start that ORACLE # cat $ORATAB | while read LINE do case $LINE in \#*) # Comment-Line in ORATAB ;; *) # Setup ORACLE RDBMS # Proceed only if third field is 'Y'. if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] then ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -` if [ "$ORACLE_SID" = '*' ] then ORACLE_SID="" fi ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -` # Put $ORACLE_HOME/bin into PATH and export. PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc # # Start SQL*NET TCP/IP Server on Root-Server or Standalone # if [ $state = "localroot" -o $state = "standalone" ] then # Does orasrv already running ? oraproc=`ps -e | grep orasrv | grep -v grep | /usr/ucb/wc -l` if [ "$oraproc" -eq 0 ] then orasrv dbaon fi fi PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora if [ -f $ORACLE_HOME/bin/sqldba ] then CMDSTART="sqldba command=startup" CMDSHUT="sqldba command=shutdown abort" else CMDSTART="ior w pfile=$PFILE" CMDSHUT="ior c" fi # Was Database correctly shutdown ? if test -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.dbf -o \ -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.ora then STATUS="-1" # sgadef${ORACLE_SID}.dbf exists else STATUS=1 # sgadef${ORACLE_SID}.dbf NOT exists fi case $STATUS in 1) # On Root-Server start Database, on Discless-Nodes # display Warning, because the Database is not available if [ -f $PFILE ] then # Database init-file exists if [ $state = "localroot" -o $state = "standalone" ] then # Start Database on Root-Server if $CMDSTART then echo "" echo "Database \"${ORACLE_SID}\" started." else echo "" echo "Database \"${ORACLE_SID}\" NOT started." fi else # Warning on Discless-Nodes echo "" echo "Warning ! There is no Database \"${ORACLE_SID}\" available on `cnodes -r`" fi else # Database init-file does not exist echo "" echo "Can't find init file for Database \"${ORACLE_SID}\"." echo "Database \"${ORACLE_SID}\" NOT started." fi ;; -1) # On Root-Server display Warning (running Database) # On Discless-Nodes Database is available if [ $state = "localroot" -o $state = "standalone" ] then echo "" echo "Database \"${ORACLE_SID}\" possibly left running when system went down (system crash?)." if $CMDSHUT # Try to shutdown the Database then if [ -f $PFILE ] then if $CMDSTART # Now ty to start the Database then echo "" echo "Database \"${ORACLE_SID}\" started." else echo "" echo "Database \"${ORACLE_SID}\" NOT started." fi else echo "" echo "Can't find init file for Database \"${ORACLE_SID}\"." echo "Database \"${ORACLE_SID}\" NOT started." fi else echo "Database \"${ORACLE_SID}\" NOT started." fi else echo "" echo "Database \"${ORACLE_SID}\" available on `cnodes -r`" fi ;; esac # End case $STATUS in fi ;; esac # End case $LINE in done # End read ORATAB File exit 0