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 thechkconfig --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 |
dario the boring said... I sustain Merouane Dichou comments.This script will work when manually invoked, but will not be invoked by linux. |
jade said... thx!You helped me a lot with the ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle problem |
jeremy said... Auto-startup failed for me with "permission denied." The root of the problem was that rsh was failing. The solution was to add .rhosts in the oracle user's home folder. .rhosts needs to contain the long server name and then the root user name, eg:servername.domain.com root .rhosts must be readable only by the owner: chmod 700 ~/.rhosts Then auto-startup should work. Awesome article -thanks! |
Roni Vered said... Simple, elegant and useful.Thanks a lot, I use this page every time I install a new database server. Cherrs, Roni. |
Kurt said... If you're going to edit dbstart, it is probably better to optionally preserve the previous functionality by changing the line to:ORACLE_HOME_LISTNER=${1:-$ORACLE_HOME} |
Santhosh said... su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME""That did not work for me. I have to change it to below to make it work: su - $ORA_OWNER -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}" |
Tim... said... Hi.The method in the article works fine for me on all RHEL versions and their clones. What Linux distro are you using? Cheers Tim... |
Dude said... Using su - $ORA_OWNER is the wrong approach as it resets the shell environment varibles. Simply omit the dash.FWIW: https://forums.oracle.com/forums/thread.jspa?threadID=2503302 |
Tim... said... Hi.On the contrary, using "su - ORA_OWNER" is the correct approach because I *want to* reset the shell variables. If I didn't, a bunch of environment variables would not be set correctly. Cheers Tim... |
Dude said... I do not recommend to rely on the Oracle account login profile, which can introduce additional problems. There are only 2 environment variables required:ORACLE_HOME (no need to export) export ORACLE_UNQNAME=orcl (11g Listener) which are normally set in the init script anyway. Su - erases these variables. Other variables are set by the dbstart utility script and read from /etc/oratab. |
Tim... said... Hi.I concede, it is more prone to error using the "su -" if people don't perform the correct profile setup, or do something like put a dodgy login.sql in the home directory. :) I will revise the article to prevent people making mistakes like this. Cheers Tim... |
DO NOT ask technical questions here, that's what my 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!
