Automating startup and shutdown of Oracle database 10g in Unix platform

Monday, September 20, 2010 ·

In linux unlike windows there are no services, which means that once Oracle is installed there are respective services also created automatically when you use  DBCA (Database Configuration Assistance) for the database installation. And, if you are going to create the database manually you could, or infact must create services manually, which in turn is provided by Oracle and can be configured through the "ORADIM" utility.

Therefore, these created services in windows have default behavior of automatic startup in every windows startup. But in linux, since there is nothing as Services, scripts  should be created and placed in the correct location so that in every startup and shutdown of the OS, these scripts are referred and the appropriate task is completed which in our case the script is about starting and shutting down the Oracle database, which is illustrated below.



1. Change line 78 of the dbstart script
 That is in file $ORACLE_HOME/bin/dbstart to “ORACLE_HOME_LISTNER=$ORACLE_HOME”

2. Edit the /etc/oratab file

vi /etc/oratab
Ensure your is with the respective and ultimately ensuring that the third option has a value of “Y”, which dictates the database should start during every startup. This wil have to something like this:

ORCL:/u01/app/oracle/product/10.2.0/db_1:Y
 

3. Create the “dbora” script inside /etc/rc.d/init.d, And have the following entries:
##############################################
#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# 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=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi
case "$1" in
    '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/lsnrctl start"
        su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
        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
        su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
        rm -f /var/lock/subsys/dbora
        ;;
esac

##############################################
4. Change the persmission of the so created startup script.

chmod 775 /etc/rc.d/init.d/dbora

5. Finally, make the automatic startup and shutdown of the database persistence.

chkconfig --add dbora

0 comments:

Search This Blog

About Me

I am an Oracle certified DBA and Apps DBA, totally loving my field of work. I have created this blog in order to save my studies in my field and share it with all.

View Asif Muhammad's profile on LinkedIn

Which is the most featurized database???

Followers

Site Traffic