1、 修改 Oracle 系統(tǒng)配置文件,把N改成Y:
sudo vi /etc/oratab
?
orcl:/oracle/oracle_home:Y
blogs:/oracle/oracle_home:Y
?
說(shuō)明:
/etc/oratab 格式為: SID:ORACLE_HOME:AUTO
把N設(shè)置為Y(大寫),只有這樣,oracle 自帶的dbstart和dbshut才能夠發(fā)揮作用。
2、 以root登錄編寫服務(wù)腳本:
如下#!/bin/bash
#
# chkconfig: 35 95 1
# description: init script to start/stop oracle database 10g, TNS listener, EMS, isqlplus
#
#
#
# match these values to your environment:
export ORACLE_BASE=/oracle/oracle_home
export ORACLE_HOME=$ORACLE_BASE
# export ORACLE_TERM=xterm
export PATH=$PATH:$ORACLE_HOME/bin
#export NLS_LANG='american_america.ZHS16GBK'
export ORACLE_SID=esales
# export DISPLAY=localhost:0
export ORACLE_USER=oracle
# see how we are called:
case $1 in
start)
su - "$ORACLE_USER"<<EOO
lsnrctl start
sqlplus /nolog<<EOS
connect / as sysdba
startup
EOS
emctl start dbconsole
isqlplusctl start
EOO
;;
stop)
su - "$ORACLE_USER"<<EOO
lsnrctl stop
sqlplus /nolog<<EOS
connect / as sysdba
shutdown immediate
EOS
emctl stop dbconsole
isqlplusctl stop
EOO
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
;;
esac
將腳本命名為oracle,保存在/etc/rc.d/init.d下
改變文件屬性:chmod 755 oracle
?
3、建立服務(wù)連接:
系統(tǒng)啟動(dòng)時(shí)啟動(dòng)數(shù)據(jù)庫(kù),我們需要以下連結(jié)∶
--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc2.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc3.d/S99oracle
$ ln -s ../init.d/oracle /etc/rc.d/rc5.d/S99oracle #rc4.d unused
--------------------------------------------------------------------------------
要在重新啟動(dòng)時(shí)停止數(shù)據(jù)庫(kù),我們需要以下連結(jié)∶
--------------------------------------------------------------------------------
$ ln -s ../init.d/oracle /etc/rc.d/rc0.d/K01oracle # 停止
$ ln -s ../init.d/oracle /etc/rc.d/rc6.d/K01oracle # 重新啟動(dòng)
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
