init to Start Oracle
Hi,
I couldn't find this anywhere, so I figured I would share (it took me a while to get this right)...
This should work on most RedHat systems, but you WILL need to set ORACLE_SID to an SID that's valid at your location.
I have RedHat Linux 7.3 and Oracle 9i Release 2 (running as the user, "oracle"). Here is the "/etc/rc.d/init.d/oracle" file:
+++++++++++++++++++++++++++++++++++++++++++++++++
#!/bin/sh
##############################################################################
# /etc/rc.d/init.d/oracle
##############################################################################
# chkconfig: - 90 10
# description: Oracle Database, Listener, and isqlplus (Apache)
##############################################################################
LOG=/var/log/oracle
if [ -x /etc/rc.d/init.d/functions ]
then
source /etc/rc.d/init.d/functions
elif [ -x /etc/init.d/functions ]
then
source /etc/init.d/functions
else
exit 1
fi
ORAENV_ASK=NO; export ORAENV_ASK
ORACLE_SID=ORCL; export ORACLE_SID
source oraenv
start() {
date +"*************** INIT ORACLE: %T %a %D" >> $LOG
echo -n "Starting Oracle Databases "
su oracle -c "$ORACLE_HOME/bin/dbstart" >> $LOG 2>/dev/null
ps -ef | grep oracle | grep ora_dbw0 > /dev/null
if [ 0 == $? ]
then
echo_success
else
echo_failure
fi
echo ""
touch /var/lock/subsys/oracle
echo -n "Starting Oracle TNS Listener"
su oracle -c "$ORACLE_HOME/bin/lsnrctl start" >> $LOG 2>/dev/null
if [ 0 == $? ]
then
echo_success
else
echo_failure
fi
echo ""
echo -n "Starting Oracle Apache/isqlplus "
su oracle -c "$ORACLE_HOME/Apache/Apache/bin/apachectl start" >> $LOG 2>/dev/null
if [ 0 == $? ]
then
echo_success
else
echo_failure
fi
echo ""
}
stop() {
date +"*************** STOP ORACLE: %T %a %D" >> $LOG 2>/dev/null
echo -n "Stopping Oracle Apache/isqlplus "
su oracle -c "$ORACLE_HOME/Apache/Apache/bin/apachectl stop" >> $LOG 2>/dev/null
if [ 0 == $? ]
then
echo_success
else
echo_failure
fi
echo ""
echo -n "Stopping Oracle TNS Listener "
su oracle -c "$ORACLE_HOME/bin/lsnrctl stop" >> $LOG 2>/dev/null
if [ 0 == $? ]
then
echo_success
else
echo_failure
fi
echo ""
echo -n "Stopping Oracle Databases "
su oracle -c "$ORACLE_HOME/bin/dbshut" >> $LOG 2>/dev/null
if [ 0 == $? ]
then
echo_success
else
echo_failure
fi
echo ""
rm /var/lock/subsys/oracle
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
# vim: ts=4 sw=4
# EOF /etc/rc.d/init.d/oracle
+++++++++++++++++++++++++++++++++++++++++++++++++
|