Home > dbora Script for RHEL > Automating Shutdown and Startup Oracle10g Database

Automating Shutdown and Startup Oracle10g Database

To automate database startup and shutdown by using the dbstart and dbshut scripts:

1. Log in as the root user.

2. Edit the oratab file for your platform.

once the instance is created, edit the “/etc/oratab” file setting the restart flag for each instance to ‘Y’.

To open the file, use one of the following commands:

$ vi /etc/oratab

3. Create a file called dbora in /etc/init.d .

$vi /etc/init.d/dbora
# Run level script to start Oracle 10g services on RedHat Enterprise Linux (RHEL4.6)
# -------------------------------------------------------------------------
# Copyright (c) 2009 Tamim Khan
# Comment/suggestion: tamimdba@gmail.com
# -------------------------------------------------------------------------
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle service
# File Location: /etc/rc.d/init.d/dbora


# check Oracle db status
function chkdb_status() {

# set username
# set password

sqlplus -s /nolog > /dev/null 2>&1 <<EOF
whenever sqlerror exit failure
connect $SUSER/$SPASS
exit success

if [ $? -ne 0 ]; then
 echo "Connection failed : DB is down"
 exit 1
 echo "Connection succeeded : DB is up"

case "$1" in
 echo  "### Starting Oracle ### "
 su - $OUSER -c "$OPATH/bin/lsnrctl start"
 su - $OUSER -c "$OPATH/bin/dbstart"
 echo  "### Stopping Oracle ### "
 su - $OUSER -c "$OPATH/bin/lsnrctl stop"
 su - $OUSER -c "$OPATH/bin/dbshut"
 $0 stop
 $1 start
 echo  "### Starting Oracle iSQL Plus ### "
 su - $OUSER -c "$OPATH/bin/isqlplusctl start"
 echo "### Note: You can access service at url:  http://$(hostname):5560/isqlplus"
 echo  "### Stopping Oracle iSQL Plus ### "
 su - $OUSER -c "$OPATH/bin/isqlplusctl stop"
 echo  "### Starting Oracle Enterprise Manager 10g Database Control ###"
 su - $OUSER -c "$OPATH/bin/emctl start dbconsole"
 echo "### Note: You can access service at url:  http://$(hostname):1158/em"
 echo  "### Stopping Oracle Enterprise Manager 10g Database Control ###"
 su - $OUSER -c "$OPATH/bin/emctl stop dbconsole"
 echo "### Oracle database status ###"
 echo $"Usage: $0 {start|stop|isqlstart|isqlstop|emstart|emstop}"
 exit 1
exit 0

The lines to start and stop the listener can be removed under Oracle 10g release 2, as the dbstart command includes an automatic start of the listener.

4. Change the group of the dbora file to the OSDBA group (typically dba), and set the permissions to 750:

$ chgrp dba dbora
$ chmod 750 dbora

5. Add dbora in checkcofig:

    $ chkconfig  --add dbora
    $ chkconfig  --level 345 dbora on
  1. sandeep
    September 26, 2011 at 5:49 pm

    it’s not working properly on RHEL5

    plz tell me that where i should create dbora file:

    either /etc/rc.d/init.d/dbora OR /etc/init.d/dbora

    thanks :

  2. September 17, 2012 at 10:18 am

    If you would like to obtain much from this piece of
    writing then you have to apply such techniques to your won
    web site.

  3. March 4, 2013 at 3:28 am

    Its such as you read my mind! You appear to understand so much about this, like
    you wrote the e book in it or something. I think that you could do with a few % to drive the message home a bit, but instead of that, that is excellent blog. A fantastic read. I’ll certainly be back.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: