Automating Startup/Shutdown of Oracle Instance, Listener and DB Control on AIX

To automate startup/shutdown Oracle instance using dbstart and dbshut scripts

1) Ensure /etc/oratab contains the following line:

<SID>:<ORACLE_HOME>:Y

where Y indicates that it wants dbstart and dbshut to startup or to shutdown instance.

2) Login as root user and create a script named /etc/dboracle with the following lines:


#! /bin/sh  -x
#
# Change the value of ORACLE_HOME to specify the correct Oracle home
# directory for your installation.

ORACLE_HOME=/gold/GLT/bin/oracle/product/10.2.0/db_1
#
# Change the value of ORACLE to the login name of the
# oracle owner at your site.
#
ORACLE=gltoracle
ORACLE_SID=GOLDTEST
PATH=${PATH}:$ORACLE_HOME/bin
HOST=`hostname`
PLATFORM=`uname`
export ORACLE_HOME ORACLE_SID PATH

case $1 in
'start')
        # Listener and instance are started by 'dbstart'
        su - $ORACLE $ORACLE_HOME/bin/dbstart $ORACLE_HOME >> /var/log/oracle 2>&1 &
        ;;
'stop')
        su - $ORACLE  $ORACLE_HOME/bin/emctl stop dbconsole >> /var/log/oracle
        # Listener and instance are shut down by 'dbstart'
        su - $ORACLE  $ORACLE_HOME/bin/dbshut $ORACLE_HOME >> /var/log/oracle 2>&1 &
        ;;
*)
        echo "usage: $0 {start|stop}"
        exit
        ;;
esac
#
exit

Note: This script can only stop Oracle Net listener for which a password has not been set. In addition, if the listener name is not the default name, LISTENER, then you must specify the listener name in the stop and start commands:

$ORACLE_HOME/bin/lsnrctl {start|stop} listener_name

3) Change the group of the dboracle file to the OSDBA group (typically dba), and set the permissions to 750

# chgrp dba dboracle
# chmod 750 dboracle

4) Create symbolic links to the dboracle script in the appropriate run-level script directories as follows.

# ln -s /etc/dboracle /etc/rc.d/rc2.d/S99dbora
# ln -s /etc/dboracle /etc/rc.d/rc2.d/K01dbora

For understanding how these scripts are used, refer to metalink 1019817.6.

5) Reboot the machine to check.

Advertisements

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: