Home >Database >Mysql Tutorial >Linux下如何自动启动Oracle服务

Linux下如何自动启动Oracle服务

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:57:38964browse

在windows下,可以在计算机服务管理里将ORACLE服务设置为自动,Linux中在Oracle安装完毕以后,如果重新启动Linux ,Oracle是不会

在windows下,可以在计算机服务管理里将Oracle服务设置为自动,Linux中在Oracle安装完毕以后,如果重新启动Linux ,Oracle是不会自动启动的,你可以通过手动调用dbstart命令来进行启动,不过这样似乎也很繁琐。我们可以通过配置Oracle的自动启动脚 本,然后利用Linux的Service来启动Oracle服务器。

首先在/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启动了。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn