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。就暫時沒有理會這些錯誤了。