程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> oracle服務開機自啟動

oracle服務開機自啟動

編輯:Oracle教程

1、修改oracle系統配置文件::/etc/oratab

vi /etc/oratab

orcl:/opt/oracle/product/10.2.0/db_1:Y

2、在 /etc/init.d/ 下創建文件oracle啟動腳本,內容如下:

#!/bin/sh 
# chkconfig: 35 80 10 
# description: Oracle auto start-stop script. 

# 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=/opt/oracle/102
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. 改變文件權限
# chmod 755 /etc/init.d/oracle

4. 添加服務
# chkconfig --level 35 oracle on

5. 使用方法
# service oracle start        //啟動oracle
# service oracle stop        //關閉oracle
# service oracle restart     //重啟oracle

6. 需要在關機或重啟機器之前停止數據庫,做一下操作
# ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle   //關機
# ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle   //重啟 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved