How to auto start and stop the database on startup and shutdown of the OS
How do you automatically start and stop the database on startup and shutdown of the Operating system using Oracle 11gR2 11.2 on Oracle Linux 5.9 x86. I tried what oracle support suggested in How to Configure a Linux x86 Box for Oracle DB Auto Start / Shutdown [ID 281912.1] as follows, but it didn't work either. Can anyone please tell me what I'm doing wrong.
[root@dgsdba init.d]# cat dbora
#! /bin/bash
#
# description: Oracle auto start-stop script.
#
# chkconfig: 2345 99 10
#
# processname: oracle
# config: /etc/oratab
# pidfile: /var/run/oracle.pid
# Source function library.
. /etc/init.d/functions
RETVAL=0
ORA_OWNER="oracle"
ORA_HOME="/u01/app/oracle/product/11.2.0/dbhome_1"
# See how we were called.
prog="oracle"
start() {
echo -n $"Starting $prog: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/dbora
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -r /var/lock/subsys/dbora
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
[root@dgsdba init.d]#