Creating scripts for automatic startup of oracle 9i on ubuntu 6.0.6
Environment:-
Server:- Ubuntu 6.0.6 with Oracle 9i database (SID:- ora9ir2).
Tools used to access VM:- putty
Description:-
There are two ways to configure oracle automatic startup:-
First Method) User 'dbstart' and 'dbshut' scripts available by oracle.
a) Configure /etc/oratab file
Modify entry in /etc/oratab for ora9ir2 database and set third paramater to 'Y'. dbstart utility uses this parameter to identify which all databases to start at boot time.
E.g,
sudo vi /etc/oratab
ora9ir2:/u01/app/oracle/product/9.2.0:Y
b) Create a file called "/etc/init.d/dbora" as the root user with correct values of ORA_HOME and ORA_OWNER, containing the following:-
#!/bin/sh
# Description: Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
#
# Set ORA_OWNER to the user id of the oracle database owner
ORA_HOME=/u01/app/oracle/product/9.2.0
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: Cannot start"
echo "Make sure ORA_HOME is set properly and"
echo "dbstart is available in $ORA_HOME/bin"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
# oracle login must not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
;;
'stop')
# Stop the Oracle databases:
# oracle login must not prompt the user for any values
su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
;;
esac
c) Set execution privileges for dbora script.
chmod 750 /etc/init.d/dbora
d) Create required links for dbora.
sudo update-rc.d dbora defaults 99
Second Method) Create your own scripts.
This method give you more control over database startup. E.g., you can start/stop related database services.
a) Create ownstart script in $ORACLE_HOME/bin directory containing following,
lsnrctl start
export ORACLE_SID=ora9ir2
sqlplus "/ as sysdba" <<EOF
startup
EOF
b) Set execution privileges for ownstart script.
chmod 755 /etc/init.d/ownstart
c) Create ownshut script in $ORACLE_HOME/bin directory containing following,
export ORACLE_SID=ora9ir2
sqlplus "/ as sysdba" <<EOF
shutdown immediate
lsnrctl stop
EOF
d) Set execution privileges for ownshut script.
chmod 755 /etc/init.d/ownshut
e) Create a file called "/etc/init.d/dbora" as the root user , containing the following:-
ORACLE_HOME=/u01/app/oracle/product/9.2.0
case "$1" in
start)
#Start Oracle database
su - oracle -c ownstart
;;
stop)
#Stop oracle database
su - oracle -c ownshut
;;
f) Set execution privileges for dbora script.
chmod 750 /etc/init.d/dbora
g) Create required links for dbora.
sudo update-rc.d dbora defaults 99
Known Issues:-
1) dbstart script causes exception "can't find init file for database"
This exception occurs where database is confiured to use SPFILE and PFILE is not available at default location.
Fix:- Edit 'dbstart' script to consider SPFILE and not PFILE. Change "PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora" (line 55) in dbstart script to "SPFILE=${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora".
Also change "if [ -f $PFILE ] ; then" (line 117) to "if [ -f $SPFILE ] ; then".
This change will use SPFILE for all database started using dbstart script.
No comments:
Post a Comment