Oracle自動起動スクリプト

2013年3月12日 Posted by PURGE

#! /bin/bash
#
# oracle: Starting Oracle database 11g
#
# chkconfig: 345 95 94
# description: Oracle Database Server
# processname: ora_

. /etc/rc.d/init.d/functions

lockfile=/var/lock/subsys/dbora
ORATAB=/etc/oratab
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1/
#ORACLE_HOME=`awk -F: '/^[^#:]+:.+:[Y]$/ { print $2; exit}' $ORATAB`
if [ x$ORACLE_HOME = "x" ]; then
    echo "There is not Y entry in $ORATAB."
    exit 1
fi
ORACLE=`ls -l $ORACLE_HOME/bin/dbstart | awk '{print $3}'`

case "$1" in
'start')
   if [ -f $lockfile ]; then
     echo $0 already started.
     exit 1
   fi
   echo -n $"Starting Oracle Database:"
   su - $ORACLE -c "$ORACLE_HOME/bin/lsnrctl start"
   su - $ORACLE -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
   su - $ORACLE -c "$ORACLE_HOME/bin/emctl start dbconsole"
   touch $lockfile
   ;;
'stop')
   if [ ! -f $lockfile ]; then
     echo $0 already stopped.
     exit 1
   fi
   echo -n $"Stopping Oracle Database:"
   su - $ORACLE -c "$ORACLE_HOME/bin/lsnrctl stop"
   su - $ORACLE -c "$ORACLE_HOME/bin/dbshut"
   su - $ORACLE -c "$ORACLE_HOME/bin/emctl stop dbconsole"
   rm -f $lockfile
   ;;
'restart')
   $0 stop
   $0 start
   ;;
'status')
   if [ -f $lockfile ]; then
     echo $0 started.
   else
     echo $0 stopped.
   fi
   ;;
*)
   echo "Usage: $0 [start|stop|status]"
   exit 1
esac

exit 0

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です