IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當(dāng)前所在位置:首頁數(shù)據(jù)庫Oracle → oracle開機自動啟動方法

oracle開機自動啟動方法

時間:2015/6/28來源:IT貓撲網(wǎng)作者:網(wǎng)管聯(lián)盟我要評論(0)

  以redhat 5.5和oracle 11g為例。安裝過程參考官方文檔,以下是實現(xiàn)oracle自啟動的方法。

  1、配置dbstart和dbshut

  在$ORACLE_HOME/bin中,有dbstart和dbshut這兩個腳本,more dbstart看一下可以看到:

  QUOTE:

  #

  # $Id: dbstart.sh.pp 11-may-2005.18:18:07 vikrkuma Exp $

  # Copyright (c) 1991, 2005, Oracle. All rights reserved.

  #

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

  #

  # usage: dbstart

  #

  # This is used to start ORACLE from /etc/rc(.local).

  # It should ONLY be executed as part of the system boot procedure.

  #

  # This will start all databases listed in the oratab file

  # whose third field is a "Y". If the third field is set to "Y" and

  # there is no ORACLE_SID for an entry (the first field is a *),

  # then this will ignore that entry.

  #

  # This requires that ASM ORACLE_SID's start with a +, and

  # that non-ASM instance ORACLE_SID's do not start with a +.

  #

  # If ASM instances are to be started with this , it cannot

  # be used inside an rc*.d directory, and should be invoked from

  # rc.local only. Otherwise, the CSS service may not be available

  # yet, and this will block init from completing the boot

  # cycle.

  #

  # Note:

  # Use ORACLE_TRACE=T for tracing this .

  #

  # The progress log for each instance bringup plus Error and Warning message[s]

  # are logged in file $ORACLE_HOME/startup.log. The error messages related to

  # instance bringup are also logged to syslog (system log module).

  # The Listener log is located at $ORACLE_HOME_LISTNER/listener.log

  ......

  可以看出這個腳本是用來啟動oracle服務(wù)的,包括listener、instance、asm instances,并且可以放到/etc/rc(.local).,同樣dbshut也是起到關(guān)閉服務(wù)的作用。

  配置系統(tǒng)使這個腳本起作用:

  1)、以root編輯/etc/oratab,類似 orcl:/u01/product/10.2.0/db_1:N 這種格式,其中orcl是你的ORACLE_SID,/u01/product/10.2.0/db_1是ORACLE_HOME,這里需要把N改為Y,即orcl:/u01/product/10.2.0/db_1:Y這樣。

  2)、以oracle編輯$ORACLE_HOME/bin/dbstart,找到其中第78行:ORACLE_HOME_LISTNER=改為你自己的路徑,或者可以改成ORACLE_HOME_LISTNER=$ORACLE_HOME

  保存腳本,以oracle用戶運行dbshut和dbstart看是否能關(guān)閉、啟動數(shù)據(jù)庫。如果不能,一般是參數(shù)設(shè)置,根據(jù)報錯找到對應(yīng)位置更改。

  2、把dbstart和dbshut加到redhat啟動服務(wù)中

  經(jīng)過上一步的配置,可以直接用dbstart命令啟動數(shù)據(jù)listener、instance、asm instances,但是還沒有啟動oracle10g的EM,ORACLE利用web頁面管理數(shù)據(jù)庫相當(dāng)方便,也是10g的一個特色,所以應(yīng)該一并啟動起該服務(wù)來。

  QUOTE:

  $ORACLE_HOME/bin/emctl start dbconsole

  因此我們可以用rc.local或者redhat服務(wù)都可以實現(xiàn)要求的開機啟動。下面分別說一下:

  1)、利用rc.local。直接把dbstart加到rc.local中,實現(xiàn)開機自動啟動。這里需要注意的是必須以oracle啟動該腳本。

  用root編輯/etc/rc.local,添加下面一行:

  QUOTE:

  su - oracle -c "/u01/product/10.2.0/db_1/bin/dbstart"

  su - oracle -c "/u01/product/10.2.0/db_1/bin/emctl start dbconsole"

  這里/u01/product/10.2.0/db_1需要替換成實際的ORACLE_HOME

  保存并退出后,reboot服務(wù)器測試一下,可以看到,當(dāng)系統(tǒng)啟動以后oracle監(jiān)聽、實例和em都已經(jīng)起來了

  2)、如果我們不用rc.local,也可以加到redhat服務(wù)中。在/etc/rc.d/init.d中添加如下腳本文件,命名為oracle:

  QUOTE:

  #!/bin/sh

  #chkconfig: 2345 99 01

  #deion: ORACLE 10g Server

  ORACLE_HOME=/u01/product/10.2.0/db_1

  if [ ! -f $ORACLE_HOME/bin/dbstart ]

  then

  echo "ORACLE cannot start"

  exit

  fi

  case "$1" in

  'start')

  echo "Starting Oracle Database..."

  su - oracle -c "$ORACLE_HOME/bin/dbstart"

  su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole"

  ;;

  'stop')

  echo "Stoping Oracle Database"

  su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"

  su - oracle -c "$ORACLE_HOME/bin/dbshut"

  ;;

  esac

  注意其中兩行注釋,網(wǎng)上很多腳本因為少了這兩行不能使服務(wù)自啟動:

  QUOTE:

  #chkconfig: 2345 99 01

  #deion: ORACLE 10g Server

  其中chkconfig:2345 99 01 是指腳本將為運行級2、3、4、5啟動oracle 10g服務(wù),啟動優(yōu)先級為99,關(guān)閉優(yōu)先級為01。

  然后以root權(quán)限:

  QUOTE:

  # cd /etc/rc2.d

  # ln -s /etc/rc.d/init.d/oracle S99oracle

  # chkconfig --list oracle

  # chkconfig --level 2345 on

  重啟系統(tǒng),就可以在啟動的過程中看到 Starting oracle,因為我們設(shè)置的優(yōu)先級為99,一般是最后啟動。[OK]以后就可以了。因為要啟動emctl,可能有點慢,等待的時間要稍微長一點。

  啟動以后可以以root執(zhí)行oracle start或者oracle stop來啟動或停止服務(wù)。

關(guān)鍵詞標(biāo)簽:oracle開機自動啟動

相關(guān)閱讀

文章評論
發(fā)表評論

熱門文章 Oracle中使用alter table來增加,刪除,修改列Oracle中使用alter table來增加,刪除,修改列oracle中使用SQL語句修改字段類型-oracle修oracle中使用SQL語句修改字段類型-oracle修使用低權(quán)限Oracle數(shù)據(jù)庫賬戶得到管理員權(quán)限使用低權(quán)限Oracle數(shù)據(jù)庫賬戶得到管理員權(quán)限Oracle對user的訪問控制Oracle對user的訪問控制

相關(guān)下載

人氣排行 ORACLE SQL 判斷字符串是否為數(shù)字的語句Oracle中使用alter table來增加,刪除,修改列的語法ORACLE和SQL語法區(qū)別歸納(1)oracle grant 授權(quán)語句如何加速Oracle大批量數(shù)據(jù)處理Oracle刪除表的幾種方法ORACLE修改IP地址后如何能夠使用Oracle 10g創(chuàng)建表空間和用戶并指定權(quán)限