Go to TogaWare.com Home Page.
GNU/Linux Desktop Survival Guide
by Graham Williams

Starting and Stopping Oracle 10g

To start and stop Oracle 10g using the "wajig start|stop" commands, we need to edit the /etc/oratab file, and create the appropriate script in /etc/init.d.

First edit the /etc/oratab file. The format of this file is:


Put a Y in the AUTO_START field of the databases you want to start automagically, and a N for the ones you don't. Your file might look like this to start databases test1 and test2, and not start test3:


Now we need to create the init.d script.

# Run-level Startup script for the Oracle Instance and Listener
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance


# if the executables do not exist -- display error

if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
        echo "Oracle startup: cannot start"
        exit 1

# depending on parameter -- startup, shutdown, restart 
# of the instance and listener or usage display 

case "$1" in
        # Oracle listener and instance startup
        echo -n "Starting Oracle: "
        su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"
        su - $ORA_OWNR -c $ORA_HOME/bin/dbstart
        touch /var/lock/subsys/oracle
        echo "OK"
        # Oracle listener and instance shutdown
        echo -n "Shutdown Oracle: "
        su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
        su - $ORA_OWNR -c $ORA_HOME/bin/dbshut
        rm -f /var/lock/subsys/oracle
        echo "OK"
        $0 stop
        $0 start
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
exit 0

(You may need to change the listener.ora to have the IP of the box, as opposed to the hostname, otherwise clients machines may not be able to connect.)

To make the script run at boot-time, and let you "wajig start|stop oracle", do the following:

ln -s /etc/init.d/oracle /etc/rc.d/rc2.d/S99oracle
ln -s /etc/init.d/oracle /etc/rc.d/rc3.d/S99oracle
ln -s /etc/init.d/oracle /etc/rc.d/rc4.d/S99oracle
ln -s /etc/init.d/oracle /etc/rc.d/rc0.d/K01oracle
ln -s /etc/init.d/oracle /etc/rc.d/rc6.d/K01oracle

Now we can start and stop oracle by:

wajig start oracle
wajig stop oracle

Copyright © 1995-2006 [email protected]
Contribue and access the PDF Version