How to Set up Automatic Startup and Shutdown of an Oracle Database on Linux without Using Oracle-Restart
$ORACLE_SID:$ORACLE_HOME:<N|Y>2) Create file /etc/init.d/dbora: Edit with your environment configuration:
#! /bin/sh # description: Oracle auto start-stop script. # # Set ORACLE_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 ORACLE_HOME.ORA_HOME= ORA_OWNER=
case "$1" in 'start') # Start the Oracle databases: # The following command assumes that the oracle login # will not prompt the user for any values # Remove "&" if you don't want startup as a background process. su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" & touch /var/lock/subsys/dbora ;; '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" & rm -f /var/lock/subsys/dbora ;; esac* You may also want to add listener commands in the script. For that, fit the following in the same syntax as shown above.
$ORACLE_HOME/bin/lsnrctl {start|stop} listener_name
3) Change the group of the dbora file to the OSDBA group (typically dba), and set the permissions to 750:
# chgrp dba dbora # chmod 750 dbora4) Create symbolic links to the dbora script:
# ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora # ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora # ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dboraAnd that's it! Now your database and listener are restarting automatically with the server. * Bonus! *.1) Register this as a service:
chkconfig --add dbora*.2) And now you can stop/start your database as an OS service:
# service dbora start # service dbora stop
Interesting: - Oracle 11gR2 documentation states the use of the dbstart and dbshut scripts are deprecated. It's supposed to be replaced by Oracle Restart. - The Oracle 12c documentation has no mention of the deprecation of dbstart and dbshut and has reinstated the documentation about them (as I linked above). So, feel free to use dbstart and dbshut in a supported manner for all versions of the database. Important: Also, note that this post is focused on Linux RHEL or OL, but you can also find this procedure documented for AIX and Solaris as per official Online Doc: Stopping and Starting Oracle Software. I hope this helps!
Ready to optimize your Oracle Database for the future?
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
Installing Oracle 11g on Ubuntu Linux 7.10 (Gutsy Gibbon)
Installing Oracle 11gR1 on Ubuntu 8.10 Intrepid Ibex
How to Fix the Status of the Oracle GI CRS After a Failed Upgrade
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.