熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

講解linux環境下Oracle的自動啟動與停止

2013-11-13 15:41:26  來源: Oracle 

   修改Oracle系統配置文件/etc/oratab

  /etc/oratab 格式為 SID:ORACLE_HOME:AUTO

  把AUTO域設置為Y(大寫)只有這樣oracle 自帶的dbstart和dbshut才能夠發揮作用我的為

  orai:/home/oracle/ora/products/:Y

   編寫服務腳本

  如下  

  #!/bin/bash

  #

  #################FUNCTION#############

  #

  # AutoStart Oracle and listener

  # AutoStop Oracle and listener

  #

  #####################################

  #

  # Created by ZhouYS

  #

  

  case $ in

  start)

  echo Starting Oracle Databases

  echo >> /var/log/oracle

  date + %T %a %D : Starting Oracle Databasee as part of system up >> /var/log/oracle

  echo >> /var/log/oracle

  su oracle c dbstart >> /var/log/oracle

  echo Done

  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 oracle c lsnrctl start >> /var/log/oracle

  echo Done

  echo

  echo >> /var/log/oracle

  date + %T %a %D : Finished >> /var/log/oracle

  echo >> /var/log/oracle

  touch /var/lock/subsys/oracle

  

  ;;

  stop)

  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 oracle c lsnrctl stop >> /var/log/oracle

  echo Done

  rm f /var/lock/subsys/oracle

  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 oracle c dbshut >>/var/log/oracle

  echo Done

  echo

  echo >> /var/log/oracle

  date + %T %a %D : Finished >> /var/log/oracle

  echo >> /var/log/oracle

  

  ;;

  restart)

  $ stop

  $ start

  

  ;;

  *)

  echo Usage: oracle {start|stop|restart}

  exit

  esac

將腳本命名為oracle保存在/etc/rcd/initd下

  改變文件屬性chmod oracle

  

  注意在windows下編輯此文件時有DOS格式字符導致在linux下不能夠正常運行建議用gedit 或用 vi編輯

  

  建立服務連接

  系統啟動時啟動數據庫我們需要以下連結∶

  

  $ ln s /initd/oracle /etc/rcd/rcd/Soracle

  $ ln s /initd/oracle /etc/rcd/rcd/Soracle

  $ ln s /initd/oracle /etc/rcd/rcd/Soracle #rcd unused

  

  

  

  

  要在重新啟動時停止數據庫我們需要以下連結∶

  

  

  

  

  $ ln s /initd/oracle /etc/rcd/rcd/Koracle # 停止

  $ ln s /initd/oracle /etc/rcd/rcd/Koracle # 重新啟動


From:http://tw.wingwit.com/Article/program/Oracle/201311/17142.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.