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)
Hi,
I still get this error
====
ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
Processing Database instance “orcl”: log file /home/vasanth/oracle/product/10.2.0/db_1/startup.log
Processing Database instance “orcl”: log file /home/vasanth/oracle/product/10.2.0/db_1/startup.log
vasanth@vasanth-desktop: ~/oracle/product/10.2.0/db_1/bin$
=====
Please assist
@Vasanth
mmmhhh ORACLE_HOME_LISTNER is not SET
try to debug the script echoing the actual value of ORACLE_HOME_LISTNER to see what is going on. If ORACLE_HOME_LISTNER is not properly set try to set it by hand directly into the script.
have a good day,
arjuna
Hi,
Thanks. Net listener works fine after setting ORACLE_HOME.
I could not connect to the database still with “./sqlplus sys as sysdba”
I get the error
“Error 6 initializing SQL*Plus
Message file spl.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory”
Also http://localhost:1158/em and http://localhost:5560/sqlplus
does not work. What settings should be done ?
Thanks,
Vasanth
Hi,
managed to make it work after checking the settings again.
Can i add the Oracle menu and it’s tools to Application menu ?
Thanks,
Vasanth
I’m happy that you solved. About the Oracle menu in the Applications menu I have no idea. I use only the shell when working on servers …
have a nice day,
Arjuna
In 11g R2, /etc/init.d/dbora file already exists.
But there is a bug.
In $ORACLE_HOME/bin/dbstart line 103 (as a case in 11g R2)
ORATAB=/etc/oratab
should be changed to
ORATAB=/u01/app/oracle/product/11.1.0/db_1/install/oratab