Automatically starting things

To automatically start an Oracle database (11.2.0 in this case) on Linux RHEL 5, first edit the /etc/oratab file to allow for the dbstart command to startup the database. The oratab file contains an entry for each database. Each entry contains three elements separated by colons:




Make sure that the start flag is set to Y.

Next, create a file orastart with the startup instruction in the /etc/init.d directory:

(I’ve added some logging instructions for better troubleshooting)

[sourcecode language=”bash”]
# chkconfig: 345 99 10
# description: Starts Oracle database
echo "=============================================" >> $LOG
echo "$(date) Starting Database" >> $LOG
su – $OWNER -c "$ORACLE_HOME/bin/lsnrctl start" >> $LOG
su – $OWNER -c $ORACLE_HOME/bin/dbstart $ORACLE_HOME >> $LOG
echo "$(date) Finished." >> $LOG

Make sure to include the chkconfig and description comments. The three numbers after the command determine the start and stop priorities for the different runlevels. In this case, for runlevels 3, 4, and 5, the start priority is 99 and the stop priority is 10.

Grant execute permissions to the file.

Finally, add the file with the startup instructions to the runlevel information:

(as root)

$ cd /etc/init.d
$ chkconfig --add orastart

To verify that the startdb file has been added you can use:

$ chkconfig --list | grep startdb
orastart         0:off   1:off   2:off   3:on    4:on    5:on    6:off

Now reboot your machine and watch the database start up.

Further reading:

Automating Database Startup and Shutdown.

6 Stages of Linux Boot Process

About chkconfig