如果每次重啟作業系統都要進行以上操作好麻煩,那麼如何讓oracle作為系統服務在開機的時候自動啟動呢?
oracle在$oracle_home/bin下提供許多對資料庫進行操作的指令碼,其中dbstart和dbshut可分別用來啟動和關閉資料庫。注意,這兩個指令碼已包含***的啟動或關閉,但並未對em進行相關的操作。使用如下命令:
/opt/oracle/11g/bin/dbstart /opt/oracle/11g #啟動資料庫例項(包含***)/opt/oracle/11g/bin/dbshut /opt/oracle/11g #關閉資料庫例項(包括***)
以上命令要成功啟動資料庫例項還得開啟oracle設定的乙個關卡:vi /etc/oratab,修改行:
orcl:/opt/oracle/11g:y #預設為orcl:/opt/oracle/11g:n
以root身份建立開機啟動oracle服務的指令碼:vi /etc/init.d/oracle,新增如下指令碼:
#!/bin/sh#chkconfig:
2345
2080
#description: oracle dbstart /dbshut
#以上兩行為chkconfig所需
ora_home=/opt/oracle/11g
ora_owner=oracle
logfile=/var/log/oracle.log
echo
"#################################
" >>$
date +"
### %t %a %d: run oracle
" >>$
if [ ! -f $/bin/dbstart ] || [ ! -f $/bin/dbshut ]; then
echo
"error: missing the script file $/bin/dbstart or $/bin/dbshut!
" >>$
echo
"#################################
" >>$
exit
fistart() -c "
$/bin/dbstart $
"echo
"###done.
"echo
"###run database control...
"su - $ -c "
$/bin/emctl start dbconsole
"echo
"###done."}
stop() -c "
$/bin/emctl stop dbconsole
"echo
"###done.
"echo
"###shutdown database...
"su - $ -c "
$/bin/dbshut $
"echo
"###done."}
case"$1
"in'start')
start >>$
;;'stop')
stop >>$
;;'restart')
stop >>$
start >>$
;;esac
date +"
### %t %a %d: finished.
" >>$
echo
"#################################
" >>$
echo
""
使用如下命令將 /etc/init.d/oracle 置為可執行檔案:
chmod a+x /etc/init.d/oracle
至此,可使用如下命令對oracle進行啟動和關閉
/etc/init.d/oracle start #啟動oracle(包括資料庫例項、***、em)/etc/init.d/oracle stop #關閉oracle
/etc/init.d/oracle restart #重啟oracle
將 oracle 新增到 chkconfig中:
chkconfig --add oracle
可使用如下命令檢視和設定oracle服務的開機啟動級別:
chkconfig |grep oracle #檢視oracle服務的開機啟動級別chkconfig --level 24
oracle off #修改oracle服務的開機啟動級別
chkconfig --level 35 oracle on
至此可使用如下命令對oracle的啟動或關閉進行管理
service oracle start #啟動service oracle stop #關閉
service oracle restart #重啟
建立連線:
ln -s /etc/init.d/oracle /etc/rc0.d/k01oracle #關機執行ln -s /etc/init.d/oracle /etc/rc6.d/k01oracle #重啟執行
posted @
2013-12-18 20:18
xingoo 閱讀(
...)
編輯收藏
Linux下Redis開機自啟(Centos)
特別說明 1.以下這些變數得配置成自己的。且 pidfile 應為 var run redis pid.不修改這裡,stop的時候關不掉。redisport 6379 exec usr redisbin redis server redis cli usr redisbin redis cli pi...
Linux下Redis開機自啟(Centos)
廢話少說,直接來步驟 1 設定redis.conf中daemonize為yes,確保守護程序開啟。2 編寫開機自啟動指令碼 vi etc init.d redis指令碼內容如下 chkconfig 2345 10 90 description start and stop redis path us...
Linux下Redis開機自啟(Centos)
1 設定redis.conf中daemonize為yes,確保守護程序開啟。2 編寫開機自啟動指令碼 vi etc init.d redis指令碼內容如下 chkconfig 2345 10 90 description start and stop redis path usr local bin...