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