Wednesday, April 10, 2013

Auto-start/stop of Oracle databases on RHEL 5

To configure Oracle databases to auto-start/stop by having the entry in /etc/oratab set to Y, requires some details to be worked on linux side. Following would require "root" privileges or co-ordination with system administrator.

Here are the steps to enable that configuration.
Step 1) Set the 3rd field in /etc/oratab to "Y" >>> this enables to oracle databases to auto-start

Step 2) As "root" user create a script dbora at following location >>> /etc/init.d
script name --> dbora
contents are as below

#!/bin/bash
# chkconfig: 35 99 10  
# Script to start and stops Oracle processes
# Set ORA_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 ORA_HOME.
#
ORA_HOME= /app/oracle/product/11.2/dbhome_1
ORA_OWNER=oracle

case "$1" in
   'start')
      # Start the TNS Listener
      su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
      # Start 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/dbstart
      touch /var/lock/subsys/dbora
      ;;

   'stop')
       # Stop the TNS Listener
      su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl 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
      rm -f /var/lock/subsys/dbora
      ;;
esac
# End of script dbora


The above script can include other components which might be called upon to start/stop in appropriate order. Here they only start/stop listener & database.

Step 3) Set script permissions:
chmod 755 /etc/init.d/dbora

Step 4) Register the Service /sbin/chkconfig --add dbora
This deals with just a simple set up, some variations may be encountered while you are dealing with different release of Oracle databases on same server & if databases are using ASM.




No comments:

Post a Comment