1、首先编写一个sh文件/etc/init.d/dbora,内容如下:
#!/bin/sh
# set ORACLE_HOME to be equivalent to the ORACLE_HOME
# from which you wish to execute dbstart and dbshut
#
ORA_HOME=/export/home/oracle/product/10.2.0
ORA_OWNER=oracle
#
if [ ! -f $ORA_HOME/bin/dbstart ] ; then
echo "oracle startup:cannot start"
exit
fi
case "$1" in
'start' )
su $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
;;
'stop')
su $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
;;
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit
2、建立启动与关闭连接
#ln -s /etc/init.d/dbora /etc/rc0.d/K10dbora
#ln -s /etc/init.d/dbora /etc/rc2.d/S99dbora
系统启动时rc2.d文件夹下,脚本启动默认参数start
系统关闭时rc0.d文件夹下,脚本停止默认参数stop
3、dbstart脚本修改
安装之后的dbstart脚本有问题,需要根据错误提示修改
a. 修改/var/opt/oracle/oratab文件,把需要自动启动的实例的条目的最后一个字母改为“Y”
orcl:/export/home/oracle/product/10.2.0:Y
b. 修改$ORACLE_HOME/bin/dbstart脚本
Oracle 10.2.0.1.0自带的dbstart脚本根据操作系统以及系统版本的不同可能会需要进行细微的调整。在Solaris10 x86 6/06版本中你可能需要对以下进行内容:
1).修改VER10LIST变量
export VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version | grep "LSNRCTL for " | cut -d' ' -f5 | cut -d'.' -f1`拆成两行,如下所示:
VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version | grep "LSNRCTL for " | cut -d' ' -f5 | cut -d'.' -f1`
export VER10LIST
2). 修改COUNT的迭加计算表达式
COUNT=$((COUNT+1)) 替换为 ((COUNT=COUNT+1))
3).在只有系统表情况下临时屏蔽
...
#if [ -e $SPFILE -o -e $SPFILE1 -o -e $PFILE ] ; then
...
#else
# $LOGMSG ""
# $LOGMSG "Can't find init file for ${INST} /"${ORACLE_SID}/"."
# $LOGMSG "Error: ${INST} /"${ORACLE_SID}/" NOT started."
#fi
4.reboot