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


一./etc/oratab说明
直接使用cat 查看这个文件:

gg1:/home/oracle> cat /etc/oratab
#

# This file is used by ORACLEutilities. It is created by root.sh
# and updated by the Database ConfigurationAssistant when creating
# a database.

# A colon, ‘:', is used as the fieldterminator. A new line terminates
# the entry. Lines beginning with a pound sign, ‘#', arecomments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME::
#
# The first and second fields are thesystem identifier and home
# directory of the databaserespectively. The third filed indicates
# to the dbstart utility that the databaseshould , “Y”, or should not,
# “N”, be brought up at systemboot time.
#
# Multiple entries with the same$ORACLE_SID are not allowed.
#
#
gg1:/u01//oracle/product/11.2.0.3/db_1:N

这里是我测试环境上的文件,在这个注释里面,对这个文件讲的比较清楚。/etc/oratab 由root.sh 脚本创建,在用DBCA 创建实例时也会更新这个文件。

当$ORACLE_SID:$ORACLE_HOME: 设置为Y时,允许实例自启动,当设置为N时,则不允许自启动。 这个文件里的配置仅仅起一个开关的作用,其并不会具体的执行启动和关闭,具体的操作由$ORACLE_HOME/bin/dbstart和dbshut 脚本来实现。 这2个脚本在执行时会检查/etc/oratab 文件里的配置,为Y时才能继续执行。

所以配置自启动和关闭的步骤如下:
(1) 配置/etc/oratab
(2) 修改$ORACLE_HOME/bin/dbstart和dbshut,并将其添加到/etc/rc(.local) 文件中。

这里是使用oracle 自带的dbstart 和dbshut脚本,如果使用自己写的脚本来启动或关闭DB 就不需要关心这个文件的设置了。

二.$ORACLE_HOME/bin/dbstart,dbshut 说明
2.1 dbstart 脚本

gg1:/u01//oracle/product/11.2.0.3/db_1/bin>cat dbstart
#!/bin/sh
#
# $Id: dbstart.sh 22-may-2008.05:05:45arogers Exp $
# Copyright (c) 1991, 2008, Oracle. Allrights reserved.
#

###################################
#
# usage: dbstart $ORACLE_HOME
#
# This script is used tostart ORACLE from /etc/rc(.local).
# It should ONLY beexecuted as part of the system boot procedure.
#
# This script will start all databaseslisted in the oratab file
# whose third field is a”Y”. If the third field is setto “Y” and
# there is no ORACLE_SID for an entry (thefirst field is a *),
# then this script will ignore that entry.
–这里就是我们之前说的,这个仅启动/etc/oratab 文件中标记为Y的实例。
#
# This script requires that ASMORACLE_SID's start with a +, and
# that non-ASM instance ORACLE_SID's do notstart with a +.
#
# If ASM instances are to be started withthis script, it cannot be used inside an rc*.d directory, and should be invokedfrom rc.local only. Otherwise, the CSS service may not be available yet, andthis script will block init from completing the boot cycle.
–如果是ASM 实例,那么只能从rc.local中调用,否则CSS 服务可能不可用。
#
# If you want dbstart to auto-start asingle-instance database that uses
# an ASM server that is auto-started by CRS(this is the default behavior
# for an ASM cluster), you must change thedatabase's ORATAB entry to use
# a third field of “W” and theASM's ORATAB entry to use a third field of “N”.
# These values specify that dbstartauto-starts the database only after
# the ASM instance is up and running.
–注意这里的W,其表示等待所有的ASM 实例启动完毕后在启动
#
# Note:
# Use ORACLE_TRACE=T for tracing thisscript.
#
# The progress log for each instancebringup plus Error and Warning message[s]
# are logged in file $ORACLE_HOME/startup.log.The error messages related to
# instance bringup are also logged tosyslog (system log module).
# The Listener log is located at$ORACLE_HOME_LISTNER/listener.log
–启动日志存放在$ORACLE_HOME/startup.log里。
#
# On all UNIX platforms except SOLARIS
# ORATAB=/etc/oratab
#
# To configure, update ORATAB withInstances that need to be started up
# 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


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 “”

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

赞赏

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

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

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

智乐兔官微