關於linux oracle自啟動 [轉]
關於oracle在linux系統下安裝後,如何在系統重啟的情況下讓服務自動啟動起來,網上有很多的教程和現成的指令碼,這裡只是個人工作中的一點經驗。
以redhat as4和oracle
10g為例。單機在安裝過程依照oracle官方的文件一步步下來,只要設定好引數、安裝好必要的包,一般不會出什麼問題。安裝好了以後系統重
啟,oracle重啟服務,網上很多人建議自己寫指令碼(其實指令碼也很簡單),這裡講的是用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服務的,包括listener、instance、asm instances,並且可以放到/etc/rc(.local).,同樣dbshut也是起到關閉服務的作用。
配置系統使這個指令碼起作用:
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看是否能關閉、啟動資料庫。如果不能,一般是引數設定,根據報錯找到對應位置更改。
2、把dbstart和dbshut加到redhat啟動服務中
經過上一步的配置,可以直接用dbstart命令啟動資料listener、instance、asm instances,但是還沒有啟動oracle10g的EM,ORACLE利用web頁面管理資料庫相當方便,也是10g的一個特色,所以應該一併啟動起該服務來。
QUOTE: |
$ORACLE_HOME/bin/emctl start dbconsole |
因此我們可以用rc.local或者redhat服務都可以實現要求的開機啟動。下面分別說一下:
1)、利用rc.local。直接把dbstart加到rc.local中,實現開機自動啟動。這裡需要注意的是必須以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伺服器測試一下,可以看到,當系統啟動以後oracle監聽、例項和em都已經起來了
2)、如果我們不用rc.local,也可以加到redhat服務中。在/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 |
注意其中兩行註釋,網上很多指令碼因為少了這兩行不能使服務自啟動:
QUOTE: |
#chkconfig: 2345 99 01 #deion: ORACLE 10g Server |
其中chkconfig:2345 99 01 是指指令碼將為執行級2、3、4、5啟動oracle 10g服務,啟動優先順序為99,關閉優先順序為01。
然後以root許可權:
QUOTE: |
# cd /etc/rc2.d # ln -s /etc/rc.d/init.d/oracle S99oracle # chkconfig --list oracle # chkconfig --level 2345 on |
重啟系統,就可以在啟動的過程中看到 Starting oracle,因為我們設定的優先順序為99,一般是最後啟動。[OK]以後就可以了。因為要啟動emctl,可能有點慢,等待的時間要稍微長一點。
啟動以後可以以root執行oracle start或者oracle stop來啟動或停止服務。
【轉自】http://www.shineblog.com/user5/net-work/archives/2009/1022166.shtml
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161195/viewspace-1051927/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux7 開機自啟動oracleLinuxOracle
- 【OEM】Oracle oem取消開機自動啟動(linux)OracleLinux
- 4.1.4 關於啟動和停止Oracle RestartOracleREST
- OracleLinux上的Oracle開關機自啟動OracleLinux
- Linux平臺Oracle開機自啟動設定LinuxOracle
- 轉載:關於oracle無法啟動儲存,記錄一下Oracle
- Oracle RAC自啟動Oracle
- 3.1.3 關於資料庫服務自動啟動資料庫
- oracle配置開機自啟動Oracle
- Oracle安裝相關Linux引數(轉)OracleLinux
- 關於linux的一點好奇心(一):linux啟動過程Linux
- 4 配置Oracle資料庫自動啟動Oracle資料庫
- Linux 新增開機自啟動Linux
- Linux開機自啟動配置Linux
- Oracle Linux 7.1 透過systemctl將Weblogic設定為開機自啟動OracleLinuxWeb
- Oracle RAC的自定義service自啟動Oracle
- 關於轉儲Oracle索引資訊的相關命令Oracle索引
- 關於Linux核心自帶GPIO LED控制Linux
- (踩坑記錄)關於docker run命令啟動elasticsearch自動退出問題DockerElasticsearch
- win10 自動重啟關閉方法_win10自動重啟怎麼關閉Win10
- Linux 新增指令碼開機自啟動Linux指令碼
- Linux 下軟體開機自啟動Linux
- 關於ID自動排序!新手求救!排序
- 突然發現linux下oracle的sqlplus不能啟動LinuxOracleSQL
- Linux配置JavaEE環境 Linux中安裝JDK、Tomcat、mysql 設定Tomcat自啟動、設定mysql自啟動LinuxJavaJDKTomcatMySql
- Oracle 12.2 Heavy swapping 資料庫自動關閉OracleAPP資料庫
- win10 代理模式自動開啟如何關掉_win10自動開啟代理怎麼關Win10模式
- redhat enterprise linux中vsftp開機自啟動RedhatLinuxFTP
- 關於jenkins自動化打包探索Jenkins
- Oracle資料庫關於SQL的執行計劃(轉)Oracle資料庫SQL
- 4.1 關於 Oracle RestartOracleREST
- Linux下的MongoDB安裝&啟動&關閉LinuxMongoDB
- win10更新自動重啟怎麼關掉_如何徹底關掉win10更新自動重啟Win10
- win10為什麼關機後自動重啟 win10關機後自動重啟的方法Win10
- 在Linux中,如何管理服務的自啟動?Linux
- TongWeb在Linux下設定開機自啟動WebLinux
- centos(linux): 列出所有的開機自啟動程式CentOSLinux
- Linux MySQL 服務設定開機自啟動LinuxMySql
- Linux Redis 服務設定開機自啟動LinuxRedis