Sunday, November 17, 2013

AUTO START AND STOP DATABASE

1. Add entry in /etc/oratab if not already there

nghlab:/u01/app/oracle/product/11.2.0/db_1:Y

2. log in as root user -

go to /etc/init.d

3. Create a file called dbora as follows – (Note This works for the default LISTENER )

#!/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/11.2.0/db_1
ORA_OWNER=oracle
#LISTENER_NAME=LISTENER
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 Group and mode of dbora file -

[root@nghlab init.d]# chgrp dba dbora
[root@nghlab init.d]# chmod 750 dbora

5. Create Soft Link ( Appropriate Run level Script)
[root@nghlab init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
[root@nghlab init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
[root@nghlab init.d]# ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora

6. TEST IT OUT -

REBOOT YOUR SERVER -

reboot -

OR Try -
/etc/init.d/dbora start
/etc/init.d/dbora stop

No comments:

Post a Comment