Thursday, August 12, 2010

Oracle Database XE on Linux



The Problem

On Linux, (I'm using Ubuntu 10.04 ) disabling autostart of Oracle XE at system boot prevents you from being able to start Oracle XE at all.

If you're installing Oracle XE on say, your personal laptop, hoping to do a bit of hobby like projects, you may not want to enable the DB to start up every time the system boots up. The DB after being installed has a configuration script ( /etc/init.d/oracle-xe configure ) that asks you if you want the DB to start up every time the computer boots up. If you chose not to start it automatically, you may realize that after the reboot, your DB does not seem to start, specifically the listener does not start, so you will be able to connect only through SQL*Plus. At this point, the
/etc/init.d/oracle-xe start
simply does not seem to do anything.




The Solution

Runlevel management.
Install Oracle XE with the 'start at boot time' option enabled or if you already installed with this disabled, enable it.

Enable/Disable Oracle XE database autostart

/etc/init.d/oracle-xe enable
enable autostart
/etc/init.d/oracle-xe disable
disable autostart



Once you have enabled autostart, you can use
and disable oracle-xe from run-levels 2,3,4 and 5. See below 


Thats it ! You're done. Now you can start/stop oracle any time using the following commands :

/etc/init.d/oracle-xe start
Start Oracle XE
/etc/init.d/oracle-xe stop
Strop Oracle XE

The run-levels correspond to the multiuser environment in the Ubuntu and other Debian flavored Linux distributions. Preventing the oracle-xe script from running in this manner is essentially configuring it to run at boot time, but conveniently telling the system to skip running the start up script.

The problem seems to be that Oracle XE uses a second configuration file for its startup scripts that maintain some of these settings. This file can be found in

/etc/default/oracle-xe

Within this file you see :
# ORACLE_DBENABLED:'true' means to load the Database at system boot.
ORACLE_DBENABLED=true

If this property is set to false, as it would be if you chose not to run start the DB at boot time, then the /etc/init.d/oracle-xe start does not work. The problem is possibly in the /etc/init.d/oracle-xe script, but this seemed a better solution than debugging and editing the script. Maybe I'll try editing the script one of these days...



Update : I'm told that I should not modify and redistribute the shell script, but if you dont mind getting your hands a bit dirty, take a look at the start() function in the script :
(The problem is that th listener is not started... Hmmm.. anything looking suspicious ?)
status=`ps -ef | grep tns | grep oracle`
        if [ "$status" == "" ]
        then
                if [ -f $ORACLE_HOME/bin/tnslsnr ]
                then
                        echo "Starting Oracle Net Listener."
                        $SU -s /bin/bash $ORACLE_OWNER -c "$LSNR  start" > /dev/null 2>&1
                fi
        fi


3 comments: