Debian 6 設定Oracle 11g R2開機自動啟動

來源:互聯網
上載者:User

Debian 6 設定Oracle 11g R2開機自動啟動

以root帳戶登入。

第一步:修改  /etc/oratab

orcl:/home/oracle/oracle/product/11.2.0/db_1:Y

其中

orcl: 是 sid

/home/oracle/oracle/product/11.2.0/db_1:是db_home

Y: 是指開機啟動Y(yes) or N(no);預設是N的,改成Y。

第二步: /etc/init.d 目錄下建立一個名為 oracle 的檔案

#!/bin/bash
#
# Run-level Startup script for the Oracle Instance and Listener
#
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance
ORA_HOME="/home/oracle/oracle/product/11.2.0/db_1"
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORA_HOME/bin/dbstart $ORA_HOME"
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"
#Optional : for Enterprise Manager software only
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl start dbconsole"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
#Optional : for Enterprise Manager software only
su - $ORA_OWNR -c "$ORA_HOME/bin/emctl stop dbconsole"
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNR -c "$ORA_HOME/bin/dbshut $ORA_HOME"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 start|stop|restart|reload"
exit 1
esac
exit 0

注意修改oracle home的目錄,此處為

/home/oracle/oracle/product/11.2.0/db_1

並變更檔許可權:

chmod 755 /etc/init.d/oracle

第三步:讓oracle檔案在系統啟動時調用

update-rc.d oracle defaults 99 01

執行這一步時,系統提示了一個警告:

insserv: warning: script 'oracle' missing LSB tags and overrides

先重啟了一下,執行lsnrctl status ,發現執行個體已啟動,開啟Toad嘎嘎兩聲,串連OK。就暫時沒有理會這些錯誤了。

聯繫我們

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