您好,登錄后才能下訂單哦!
環(huán)境說明:
ORACLE_SID= orcl
ORACLE_BASE=/oracle/app/oracle
ORACLE_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
(以下操作都用root執(zhí)行)
1. 修改Oracle系統(tǒng)配置文件:/etc/oratab,只有這樣,Oracle 自帶的dbstart和dbshut才能夠發(fā)揮作用。
# vi /etc/oratab , 將 ORACLE_SID:ORACLE_HOME:Y 相應(yīng)模塊替換 ,如下
orcl:/oracle/app/oracle/product/11.2.0/dbhome_1:Y
2. 在 /etc/init.d/ 下創(chuàng)建文件oracle,內(nèi)容如下: (指定該環(huán)境的ORA_HOME=XX 路徑)
#!/bin/bash
#chkconfig:345 61 61
#description:Apache
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/oracle/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle
if [ ! -f $ORA_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
echo "Starting Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
echo "Done"
# Start the Listener:
echo "Starting Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
echo "Done."
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
touch /var/lock/subsys/oracle
;;
'stop')
# Stop the Oracle Listener:
echo "Stoping Oracle Listeners ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
echo "Done."
rm -f /var/lock/subsys/oracle
# Stop the Oracle Database:
echo "Stoping Oracle Databases ... "
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
echo "Done."
echo ""
echo "-------------------------------------------------" >> /var/log/oracle
date +" %T %a %D : Finished." >> /var/log/oracle
echo "-------------------------------------------------" >> /var/log/oracle
;;
'restart')
$0 stop
$0 start
;;
esac
3. 改變文件權(quán)限
# chmod 755 /etc/init.d/oracle
4. 添加服務(wù)
# chkconfig --level 35 oracle on
5. 需要在關(guān)機(jī)或重啟機(jī)器之前停止數(shù)據(jù)庫,做一下操作
# ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle //關(guān)機(jī)
# ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle //重啟
6. 使用方法
# service oracle start //啟動(dòng)oracle
# service oracle stop //關(guān)閉oracle
# service oracle restart //重啟oracle
7. 測試
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。