Automatic Oracle 10g Startup and Shutdown at Ubuntu Linux system boot
Set the restart flag to “Y” in /etc/oratab, from something like this
dbname:/u01/app/oracle/product/10.2.0/db_1:N
to something like
dbname:/u01/app/oracle/product/10.2.0/db_1:Y
Copy&paste the boot script code that follows into /etc/init.d/dbora (the file dbora doesn’t exists, so create it) and modify the bold values to reflect your installation:
#!/bin/sh
# description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_HOME PATH
ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
;;
esac
Assign proper script privileges:
chmod 750 /etc/init.d/dbora
Create the symbolic links related to boot runlevels [since I'm a long-time-Slackware-user and pretty new to Ubuntu, I'm not well versed about Ubuntu boot system so feel free to correct me (the comments are at the end of the post)]:
ln -s /etc/init.d/dbora /etc/rc0.d/k01dbora ln -s /etc/init.d/dbora /etc/rc1.d/k01dbora ln -s /etc/init.d/dbora /etc/rc2.d/S99dbora ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora ln -s /etc/init.d/dbora /etc/rc4.d/S99dbora
at the end you should have something like this:
lrwxrwxrwx 1 root root 17 2008-07-16 14:16 /etc/rc0.d/k01dbora -> /etc/init.d/dbora lrwxrwxrwx 1 root root 17 2008-07-16 14:16 /etc/rc1.d/k01dbora -> /etc/init.d/dbora lrwxrwxrwx 1 root root 17 2008-07-16 14:16 /etc/rc2.d/S99dbora -> /etc/init.d/dbora lrwxrwxrwx 1 root root 17 2008-07-16 14:16 /etc/rc3.d/S99dbora -> /etc/init.d/dbora lrwxrwxrwx 1 root root 17 2008-07-16 14:16 /etc/rc4.d/S99dbora -> /etc/init.d/dbora
Release 2 bug: inside /u01/app/oracle/product/10.2.0/db_1/bin/dbstart there is a bug that will prevent the listener to start (Failed to auto-start Oracle Net Listener using /ade/vikrkuma_new/oracle/bin/tnslsnr); to solve change line 78 from
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle/bin/tnslsnr
to
ORACLE_HOME_LISTNER=$ORACLE_HOME
(in this article a modified version of the script at http://www.oracle-base.com/articles/linux/AutomatingDatabaseStartupAndShutdownOnLinux.php)