This page covers Oracle Auto Restart and automatically stopping and starting an Oracle Database on Linux and UNIX restart.
In the /etc/oratab file you might have to set the flags to Y (traditionally this has always been the default).
RH4 for Oracle10g may also have an incorrect setting for the lsnrctl program that prevents listener startup in an ASM installation.
The Startup & Shutdown Script
Add this file /etc/init.d/oracle:
#!/bin/sh # chkconfig: 345 95 30 # description: Oracle auto start-stop script. ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 case "$1" in 'start') su - oracle -c $ORACLE_HOME/bin/dbstart #Database - handles multiple s su - oracle -c "$ORACLE_HOME/bin/lsnrctl start" #Listener su - oracle -c "$ORACLE_HOME/bin/lsnrctl dbsnmp_start" #Agent (might be installed elsewhere with RAC and/or a multiple database environment) exit 0 ;; 'stop') su - oracle -c "$ORACLE_HOME/bin/lsnrctl dbsnmp_stop" #Agent (might be installed elsewhere with RAC and/or a multiple database environment) su - oracle -c "$ORACLE_HOME/bin/lsnrctl stop" su - oracle -c $ORACLE_HOME/bin/dbshut ;; *) echo "usage: start or stop" exit 0 ;; esac exit 0
Setting the Shutdown & Startup Script to Execute on Operating System Restart
Automate the execution of the /etc/init.d script by adding script copies or symbolic links to the startup and shutdown directory, ie. the /etc/rc2.d and /etc/rc0.d directories respectively.
The shutdown directory is /etc/rc0.d, which will execute process (K)ill scripts on *NIX shutdown where those scripts are executed in order of the integers in the filenames, ie. K02test1 is executed before K03test2. Place the oracle shutdown scripts above K00<name> but as close to K00<name> as possible, ie. execute the Oracle process shutdown first.
cd /etc/rc0.d ln -s /etc/init.d/oracle K30oracle
The startup directory is /etc/rc2.d. Note that the startup directory contains both (K)ill and (S)tartup scripts, or links. If anything needs to be killed before starting when *NIX starts-up then this is where it goes. Place the oracle startup link in the sequence of file/link names as far to the end of the list as possible.
cd /etc/rc2.d ln -s /etc/init.d/oracle S95oracle
chmod 755 /etc/init.d/oracle
Please note that this page was constructed from a Solaris blade server environment but should apply to Linux and other flavors of UNIX as well.