CentOS 6.4下讓Oracle開機啟動

來源:互聯網
上載者:User

CentOS 6.4下讓Oracle開機啟動

目標:在CentOS 6.4下讓Oracle開機啟動

方案:首先添加 啟動,關閉,重啟Oracle的服務和執行個體的服務;然後把這個服務添加到系統服務的運行層級。

設定CentOS下開機自動啟動Oracle 

步驟:

1,新增service

執行命令:

# vi /etc/rc.d/init.d/oracle

Oracle檔案的內容為:

#! /bin/bash
# chkconfig: 234 61 61
# description: Oracle 11g AutoRun Service
# /etc/rc.d/init.d/oracle
 
case "$1" in
    start)
        # starts oracle listener and instance
        echo "Starting Oracle Database:"
        su - oracle -lc "lsnrctl start"
        su - oracle -lc dbstartup
        ;;
    stop)
        # shutdown oracle listner and instance
        echo "Shuting down Oracle Database:"
        su - oracle -lc "lsnrctl stop"
        su - oracle -lc dbshutdown
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
    echo "Usage: {start|stop|reload|restart}"
    exit 1
esac
exit 0

注意:指令碼中添加至少兩行注釋行(第3步中),第一行告訴chkconfig該服務的運行層級;第二行添加關於服務的簡要說明。

以上指令碼中涉及到的兩個指令碼:dbstart和dbshut

2,編輯dbstartup和dbshutdown
執行命令
$ vi $ORACLE_HOME/bin/dbstartup
內容為:
#dbstartup
#/opt/oracle/102/bin
sqlplus / as sysdba <<EOF
startup
exit
EOF
vi$ORACLE_HOME/bin/dbshutdown
內容為:
#dbshutdown
#/home/oracle/102/bin
sqlplus / as sysdba <<EOF
shutdown immediate
exit
EOF

3,檢查啟動指令碼是否正確

# cd /etc/rc.d/init.d
# ./oracle start
# ./oracle stop
 
4,把建立好的oracle服務添加到系統層級
執行如下命令:
# chmod 750 /etc/rc.d/init.d/oracle
# chkconfig --level 234 oracle on
# chkconfig --add oracle

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.