Linux下如何自動啟動Oracle服務

來源:互聯網
上載者:User

在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啟動了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.