Linux下oracle开机自动启动与oratab、dbstart脚本说明2


# Start of dbstartupscript
#
# Loop for every entry in oratab file andand try to start
# that ORACLE.
#
# ASM instances need to be started before'Database instances'
# ASM instance is identified with ‘+'prefix in ORACLE_SID
# Following loop brings up ASM instance[s]

cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
*)
ORACLE_SID=`echo $LINE | awk -F: ‘{print $1}' -`
if[ “$ORACLE_SID” = ‘*' ] ; then
#same as NULL SID – ignore this entry
ORACLE_SID=””
continue
fi
#Proceed only if last field is ‘Y'.
if[ “`echo $LINE | awk -F: ‘{print $NF}' -`” = “Y” ] ; then
#If ASM instances
if [ `echo $ORACLE_SID | cut -b 1` = ‘+' ]; then
INST=”ASM instance”
ORACLE_HOME=`echo $LINE | awk -F: ‘{print $2}' -`
# Called scripts use same home directory
export ORACLE_HOME
# file for logging script's output
LOG=$ORACLE_HOME/startup.log
touch $LOG
chmod a+r $LOG
echo “Processing $INST \”$ORACLE_SID\”: log file$ORACLE_HOME/startup.log”

fi
fi
;;
esac
done

# exit if there was any trouble bringing upASM instance[s]
if [ “$?” != “0” ] ;then
exit 2
fi

#
# Following loop brings up ‘Database instances'
#
cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
*)
ORACLE_SID=`echo $LINE | awk -F: ‘{print $1}' -`
if[ “$ORACLE_SID” = ‘*' ] ; then
#same as NULL SID – ignore this entry
ORACLE_SID=””
continue
fi
#Proceed only if last field is ‘Y'.
if[ “`echo $LINE | awk -F: ‘{print $NF}' -`” = “Y” ] ; then
#If non-ASM instances
if [ `echo $ORACLE_SID | cut -b 1` != ‘+' ]; then
INST=”Database instance”
ORACLE_HOME=`echo $LINE | awk -F: ‘{print $2}' -`
# Called scripts use same home directory
export ORACLE_HOME
# file for logging script's output
LOG=$ORACLE_HOME/startup.log
touch $LOG
chmod a+r $LOG
echo “Processing $INST \”$ORACLE_SID\”: log file$ORACLE_HOME/startup.log”

fi
fi
;;
esac
done

#
# Following loop brings up ‘Databaseinstances' that have wait state ‘W'
#
cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
*)
ORACLE_SID=`echo $LINE | awk -F: ‘{print $1}' -`
if[ “$ORACLE_SID” = ‘*' ] ; then
#same as NULL SID – ignore this entry
ORACLE_SID=””
continue
fi
#Proceed only if last field is ‘W'.
if[ “`echo $LINE | awk -F: ‘{print $NF}' -`” = “W” ] ; then
W_ORACLE_SID=`echo $LINE | awk -F: ‘{print $1}' -`
#DB instances with ‘W' (wait state) have a dependency on ASM instances via CRS.
#Wait here for ‘all' ASM instances to become available.
cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
*)
ORACLE_SID=`echo $LINE | awk -F: ‘{print $1}' -`
if [ “$ORACLE_SID” = ‘*' ] ; then
# same as NULL SID – ignore this entry
ORACLE_SID=””
continue
fi
if [ `echo $ORACLE_SID | cut -b 1` = ‘+' ]; then
INST=”ASM instance”
ORACLE_HOME=`echo $LINE | awk -F: ‘{print $2}' -`
if [ -x $ORACLE_HOME/bin/srvctl ] ; then
COUNT=0
NODE=`olsnodes -l`
RNODE=`srvctl status asm -n $NODE | grep “$ORACLE_SID isrunning”`
RC=$?
while [ “$RC” != “0” ]; # wait until this comes up!
do
COUNT=$((COUNT+1))
if [ $COUNT = 5 ] ; then
# 5 tries with 60 sec interval=> 5 minutes timeout
$LOGMSG “Error: Timed outwaiting on CRS to start ASM instance $ORACLE_SID”
exit $COUNT
fi
$LOGMSG “Waiting for Oracle CRS service to start ASM instance$ORACLE_SID”
$LOGMSG “Wait $COUNT.”
sleep 60
RNODE=`srvctl status asm -n $NODE | grep “$ORACLE_SID isrunning”`
RC=$?
done
else
$LOGMSG “Error: \”${W_ORACLE_SID}\” has dependency on ASMinstance \”${ORACLE_SID}\””
$LOGMSG “Error: Need $ORACLE_HOME/bin/srvctl to check thisdependency”
fi
fi # asm instance
;;
esac
done # innner while
fi
;;
esac
done # outer while

# by now all the ASM instances have come upand we can proceed to bring up
# DB instance with ‘W' wait status

cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab
*)
ORACLE_SID=`echo $LINE | awk -F: ‘{print $1}' -`
if[ “$ORACLE_SID” = ‘*' ] ; then
#same as NULL SID – ignore this entry
ORACLE_SID=””
continue
fi
#Proceed only if last field is ‘W'.
if[ “`echo $LINE | awk -F: ‘{print $NF}' -`” = “W” ] ; then
INST=”Database instance”
if [ `echo $ORACLE_SID | cut -b 1` = ‘+' ]; then
$LOGMSG “Error: ${INST} \”${ORACLE_SID}\” NOTstarted”
$LOGMSG “Error: incorrect usage: ‘W' not allowed for ASMinstances”
continue
fi
ORACLE_HOME=`echo $LINE | awk -F: ‘{print $2}' -`
#Called scripts use same home directory
export ORACLE_HOME
#file for logging script's output
LOG=$ORACLE_HOME/startup.log
touch $LOG
chmod a+r $LOG
echo “Processing $INST \”$ORACLE_SID\”: log file$ORACLE_HOME/startup.log”

fi
;;
esac
done
gg1:/u01//oracle/product/11.2.0.3/db_1/bin>

声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《Linux下oracle开机自动启动与oratab、dbstart脚本说明2
本文地址:https://www.zhiletu.com/archives-448.html
关注公众号:智乐兔

赞赏

wechat pay微信赞赏alipay pay支付宝赞赏

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微