[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
running Oracle dbstart in the init script
Hi !!
I hace installed Oracle on rhl 6.2 box
It is working perfectly fine. Now I wanted to start my instance
automatically
using rc init scripts. But some how it is not working
I am enclosing the script which I am using. When I run it it says
[Failed]
please guide.
With best wishes
Sanjay Gupta
------------------------------
ORACLE_OWNER=oracle
ORATAB=/etc/oratab
CONNECT_STRING="internal as sysdba"
SHUTDOWN_STRING='shutdown immediate'
STARTUP_STRING='startup'
ORACLE_OWNER_HOME=/home/oracle
# is_running sid
isrunning() {
ps -u $ORACLE_OWNER -o cmd | fgrep -q ora_pmon_$1
}
oratab() {
sed -n \
'-es|#.*||' \
'-es|^\([^:]*:\)[ \t]*:|\1'$ORACLE_OWNER_HOME':|' \
'-es|^[ \t]*\([a-zA-Z0-9_]\{1,8\}\)[ \t]*:[ \t]*\([^: ]*\)[ \t]*:[
\t]*|\1 \2 |p' \
$ORATAB
}
#
## do_oracle ORACLE_HOME ORACLE_SID COMMAND
do_oracle() {
errs=`
echo "$3" | \
ORACLE_HOME="$1" \
NLS_LANG=american_america.us7ascii \
ORACLE_SID=$2 \
LD_LIBRARY_PATH=$1/lib \
/usr/sbin/su $ORACLE_OWNER $1/bin/sqlplus -s "$CONNECT_STRING" \
2>&1`
}
#
# startup ORACLE_HOME ORACLE_SID
startup() {
echo -n " ...startup instance $2:"
do_oracle $1 $2 "$STARTUP_STRING"
if isrunning $2 ; then
echo_success
else
initlog $INITLOG_ARGS -n "$ORACLE_OWNER[startup:$2]" -e2 -s "$errs"
echo_failure
fi
echo
}
## shutdown ORACLE_HOME ORACLE_SID
shutdown() {
echo -n " ...shutdown instance $2:"
do_oracle $1 $2 "$SHUTDOWN_STRING"
if isrunning $2 ; then
initlog $INITLOG_ARGS -n "$ORACLE_OWNER[shutdown:$2]" -e2 -s "$errs"
echo_failure
else
echo_success
fi
echo
}
notify() {
if [ -z "$noted" ] ; then
echo "$notify Oracle Database(s):"
noted=y
fi
}
noted=
. /etc/rc.d/init.d/functions
case "$1" in
restart|reload)
shmmax
notify=Restarting
oratab | \
while read sid home start ; do
echo $sid $home $start
if isrunning $sid ; then
notify
shutdown "$home" $sid
elif [ "$start" != Y -a "$start" != y ] ; then
continue
else
notify
fi
startup $home $sid
done
touch $lk
;;
startup|start)
shmmax
notify="Starting Up"
oratab | \
while read sid home start ; do
[ "$start" = Y -o "$start" = y ] || continue
if isrunning $sid ; then : ; else
notify
startup $home $sid
fi
done
touch $lk
;;
stop|shutdown|shut)
running=`ps -u "$ORACLE_OWNER" -o cmd | sed -n 's|^ora_pmon_||p'`
notify="Shutting Down"
for sid in $running ; do
home=`awk -F: '$1 == "'"$sid"'" { print $2; exit; }' $ORATAB`
[ -n "$home" ] || home=$ORACLE_OWNER_HOME
notify
shutdown $home $sid
done
rm -f $lk
;;
*)
echo "Usage: $0 {start|stop|reload|restart}" >&2
exit 1
;;
esac