Friday, January 18, 2013

Auto Start Oracle on Linux

Create the file /etc/init.d/dbora like this :

#!/bin/bash
#
# chkconfig: 35 99 10
# description: Starts and stops Oracle processes
#
ORA_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 <--- to be changed
ORA_OWNER=oracle

case "$1" in
'start')
# Start the Oracle databases:
echo "Starting the Oracle databases"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
# Start the TNS listener
# su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the TNS listener
# su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
# STOP the Oracle databases
echo "Shutting down the Oracle databases"
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
rm -f /var/lock/subsys/dbora
;;
*)
echo "Usage: dbora (start|stop)"
exit 1
esac

Then, issue the commands :

chmod 755 /etc/init.d/dbora
/sbin/chkconfig dbora on

Check also in the file /etc/oratab that the database(s) are configured to start automatically (you need a Y at the end of the line for each database :

ex :

APPSPROD:/u01/app/oracle/product/11.2.0/dbhome_1:Y

That's all !

 

Courtesy  :Michel Berger

No comments:

Post a Comment