Oracle DBA, How To, Error, Cause and Action

Making Oracle Database Autostart

To make this simple, I just say there are three main tasks need to be completed
1. Edit oratab
2. Create dbora script
3. Create the symbolic links

Task 1
To make the Oracle database autostart every time the server is started is to edit the oratab file.

oratab file is located in /etc/oratab

vi /etc/oratab


There will be list of Oracle instances in the oratab file, for my case I only have 1.
Locate the instance you want to be autostart, the setting is

(Instance Name):(The oracle home):(N for not auto start and Y for Yes autostart)

Replace the N with Y to make it autostart.


Task 2
Following Task need to be perform with root account.
We prepare the dbora file and place the file in following directory /etc/init.d
For
Solaris also in /etc/init.d
AIX in /etc
HPUX in /sbin/init.d

Following is the dbora script

#!/bin/bash
#
# chkconfig: 35 99 10
# description: Starts 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=/u01/app/oracle/product/11.1.0/db_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


Change following accordingly

ORA_HOME=/u01/app/oracle/product/11.1.0/db_1
ORA_OWNER=oracle

$ORA_HOME/bin/lsnrctl start listener_name (specify your listener name if it is not default)

$ORA_HOME/bin/lsnrctl stop listener_name (specify your listener name if it is not default)


For above run level:

0 = halt
1 = Single-user mode
2 = Basic multi-user mode (without networking)
3 = Full (text based) multi-user mode
4 = X11 with KDM/GDM/XDM (session managers) multi-user mode for slackware Linux
5 = Full (GUI based) multi-user mode
6 = reboot

Our run level is 3 and 5 with priority 10 to start and 99 to kill.

change the group owner of the file to dba and the permission to 750

chgrp dba dbora
chmod 750 dbora


To test above script execute it with root account

test start
./dbora start

test shutdown
./dbora stop


Task 3
Create the service link

chkconfig --del dbora
chkconfig --add dbora
chkconfig dbora on
chkconfig --list |grep dbora


If you issue the chkconfig on dbora, will then overwirte the run level become 2 3 4 5, so we just leave it there.



Now you have the oracle database start and shutdown automated whenever you start and shutdown your server.

No comments:

Post a Comment

Thanks for your comment.