Linux下如何自动启动Oracle服务

2014-11-24 17:52:25 · 作者: · 浏览: 0

首先在/etc/rc.d/init.d/目录下配置Oracle的服务文件。


touch oracle10g
chmod a+x oracle10g


然后编辑此oracle10g文件。内容如下。


# !/bin/bash
# whoami
# root
# chkconfig: 345 51 49
# description: starts the oracle dabase deamons
#
ORA_HOME=/opt/oracle
ORA_OWNER=oracle
case "{GetProperty(Content)}" in
'start')
echo -n "Starting oracle10g: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" &
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
touch /var/lock/subsys/oracle10g
echo
;;


'stop')
echo -n "shutting down oracle10g: "
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" &
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
rm -f /var/lock/subsys/oracle10g
echo
;;


'restart')
echo -n "restarting oracle10g: "
{GetProperty(Content)} stop
{GetProperty(Content)} start
echo
;;
*)
echo "usage: oracle10g { start | stop | restart }"
exit 1


esac
exit 0


保存文件,退出以后,添加并启动察看服务。


/sbin/chkconfig --add oracle10g
/sbin/chkconfig --list oracle10g


重新启动Linux的时候,如果看到启动项Oracle出现OK,代表Oracle成功随Linux启动了。