Installed 11g release 2 , and wanted it to start and stop when booting and stopping the system. Taking into consideration that most of the standard stop-scripts are causing the database to ‘crash’ without knowing it. Click here for an explanation. Thanks Frits!

Steps:

1. In /etc/oratab, put the start parameter on Y, like this: ‘devdb:/software/oracle/product/11.2.0/dbhome_1:Y’

2. create file /etc/init.d/oracle (change the ORACLE_HOME) :

#!/bin/bash
#
# oracle Init file for starting and stopping
# Oracle Database. Script is valid for 10g and 11g versions.
#
# chkconfig: 35 80 30
# description: Oracle Database startup script

# Source function library.

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

ORACLE_OWNER=”oracle”
ORACLE_HOME=”/software/oracle/product/11.2.0/dbhome_1″
RETVAL=0

case “$1″ in
start)
echo -n $”Starting Oracle DB:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/dbstart $ORACLE_HOME”
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/oracle
;;
stop)
echo -n $”Stopping Oracle DB:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/dbshut $ORACLE_HOME”
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/oracle
;;
*)
echo $”Usage: $0 {start|stop}”
esac

3. Make it active (as root):
chmod 750 /etc/init.d/oracle
chkconfig –add oracle –level 0356

4. For the dbconsole, create ‘/etc/init.d/oraemctl’ (change the ORACLE_HOME):

#!/bin/bash
#
# oraemctl Starting and stopping Oracle Enterprise Manager Database Control.
# Script is valid for 10g and 11g versions.
#
# chkconfig: 35 80 30
# description: Enterprise Manager DB Control startup script

# Source function library.

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

ORACLE_OWNER=”oracle”
ORACLE_HOME=”/software/oracle/product/11.2.0/dbhome_1″
RETVAL=0

case “$1″ in
start)
echo -n $”Starting Oracle EM DB Console:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole”
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/oraemctl
;;
stop)
echo -n $”Stopping Oracle EM DB Console:”
su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole”
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/oraemctl
;;
*)
echo $”Usage: $0 {start|stop}”
esac

5. Make it active (as root):

chmod 750 /etc/init.d/oraemctl
chkconfig –add oraemctl –level 0356

6. Due to a bug (8716161) , dbconsole will not start if the variable ORACLE_UNQNAME is not set.

Added this in /etc/profile:

if [ $USER = “oracle” ] ; then
if [ $SHELL = “/bin/ksh” ] ; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
export ORACLE_UNQNAME=devdb
umask 022
fi