# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:
# An example entry:
# main:/usr/lib/oracle/emagent_10g:Y
#
# Overall algorithm:
--启动顺序
# 1) Bring up all ASM instances with 'Y'entry in status field in oratab entry
--启动状态为Y的所有ASM 实例
# 2) Bring up all Database instances with'Y' entry in status field in
# oratab entry
--启动所有状态为Y的数据库实例
# 3) If there are Database instances with'W' entry in status field
# then
# iterate over all ASM instances (irrespective of 'Y' or 'N') AND
# wait for all of them to be started
# fi
--如果数据库的状态为W,则等待ASM 实例启动完毕,再启动
# 4) Bring up all Database instances with'W' entry in status field in
# oratab entry
--启动所有状态为W的数据库实例
#
#####################################
LOGMSG="logger -puser.alert -s "
trap 'exit' 1 2 3
# for script tracing
case $ORACLE_TRACE in
T)set -x ;;
esac
# Set path if path not set (if called from/etc/rc)
SAVE_PATH=/bin:/usr/bin:/etc:${PATH} ;export PATH
SAVE_LLP=$LD_LIBRARY_PATH
# First argument is used to bring up OracleNet Listener
ORACLE_HOME_LISTNER=$1
if [ ! $ORACLE_HOME_LISTNER ] ; then
echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start OracleNet Listener"
echo "Usage: $0 ORACLE_HOME"
else
LOG=$ORACLE_HOME_LISTNER/listener.log
#Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
# adifferent ORACLE_HOME for each entry in the oratab.
export ORACLE_HOME=$ORACLE_HOME_LISTNER
#Start Oracle Net Listener
if[ -x $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
echo "$0: Starting Oracle Net Listener" >> $LOG2>&1
VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version | grep "LSNRCTLfor " | cut -d' ' -f5 | cut -d'.' -f1`
export VER10LIST
else
echo "Failed to auto-start Oracle Net Listener using$ORACLE_HOME_LISTNER/bin/tnslsnr"
fi
fi
# Set this in accordance with the platform
ORATAB=/etc/oratab
if [ ! $ORATAB ] ; then
echo "$ORATAB not found"
exit 1;
fi
# Checks Version Mismatch between Listenerand Database Instance.
# A version 10 listener is required for anOracle Database 10g database.
# Previous versions of the listener are notsupported for use with an Oracle
# Database 10g database. However, it ispossible to use a version 10 listener
# with previous versions of the Oracledatabase.
checkversionmismatch() {
if[ $VER10LIST ] ; then
VER10INST=`sqlplus -V | grep "Release " | cut -d' ' -f3 | cut-d'.' -f1`
if [ $VER10LIST -lt $VER10INST ] ; then
$LOGMSG "Listener version $VER10LIST NOT supported with Databaseversion $VER10INST"
$LOGMSG "Restart Oracle Net Listener using an alternateORACLE_HOME_LISTNER:"
$LOGMSG "lsnrctl start"
fi
fi
}
# Starts a DatabaseInstance
startinst() {
#Called programs use same database ID
export ORACLE_SID
#Put $ORACLE_HOME/bin into PATH and export.
PATH=$ORACLE_HOME/bin:${SAVE_PATH} ; export PATH
#add for bug # 652997
LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${SAVE_LLP} ; export LD_LIBRARY_PATH
PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
SPFILE=${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora
SPFILE1=${ORACLE_HOME}/dbs/spfile.ora
echo ""
echo "$0: Starting up database \"$ORACLE_SID\""
date
echo ""
checkversionmismatch
#See if it is a V6 or V7 database