Aggregator | Books | Industry News | Firefox Plugins | Social | Links

Comments

Automating Database Startup and Shutdown on Linux - Use these methods to automatically startup and shutdown your database instances when your system starts and stops.



Merouane Dichou said...

Hi,

should add touch /var/lock/subsys/dbora to start and rm -f /var/lock/subsys/dbora to stop
why ?
because /etc/rc.d/rc script looks at /var/lock/subsys/SVC_NAME to
see if a service is running.
if the file do not exist then the stop (S10dbora) will not be executed and the database will not be shutdown (clean)
tested in redhat 3.0

rob said...

su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME""

contains one extra " on the end

Tim... said...

Many thanks for spotting the typo. I've corrected it now.

Cheers

Tim...

Tomas said...


Excellent to-the-point article on scripting starting/stopping of 10G.

Thanks for the heads-up on the wrong PATH in dbstart.

I prefer the non-RSH method. That way I don't have to worry about another potentially insecure service listening for connections.

Dave said...

Thanks for this - excellent work - the scripts are just what I was looking for.

Mark said...

I might add that when adding the service via checkconfig, it is better to use the

chkconfig --add dbora

this will use the chkconfig line in the dbora script and set up both K and S RC scripts. I believe the line as written will only set up the S scripts, if dbora has never been added...

Ron said...

Thanks for the great article

Andrei said...

Here is dbora that works better for me, it shows process status when using system-config-services.

Onse dbora added to /etc/init.d say

# chkconfig --add dbora

so that dbora will appear in system-config-services applet.

This script will work only and only if ORA_OWNER environment has been properly configured with ORACLE_HOME and /etc/oratab is OK as well

So here is my dbora
--
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

ORA_OWNER=oracle

# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 1
fi

orastatus() {
status ora_pmon_BUBAMARA
RETVAL=$?
status tnslsnr
RETVAL2=$?
if [ $RETVAL -ne 0 ] ; then
return $RETVAL
fi
if [ $RETVAL2 -ne 0 ] ; then
return $RETVAL2
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
# Assumes that ORA_OWNER environment has been
# setup properly as well as /etc/oratab
su - $ORA_OWNER -c "dbstart $ORACLE_HOME"
su - $ORA_OWNER -c "lsnrctl start"
;;
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 "dbshut $ORACLE_HOME"
su - $ORA_OWNER -c "lsnrctl stop"
;;
status)
orastatus
;;
*)
echo $"Usage: $0 {start|stop|status}"
exit 2
esac

MMcGee said...

Very helpful script. You might add that if you have problems with the su - "$ORA_OWNER" commands it might be because the Oracle shell variables are not set for that user or might be . This can be confusing since you think you set them in the dbora script...but those from root are not passed to that user...

dario the boring said...

I sustain Merouane Dichou comments.

This script will work when manually invoked, but will not be invoked by linux.


Don't ask technical questions here, that's what the forum is for!

These comments should relate to the contents of a specific article. Constructive criticism is good. Advertising and offensive comments are bad and will be deleted!

Add your comments here.
Name
Comment