測試機總是斷電,導致重啟後Oracle不自動重啟,需要手工操作,因此可以設定成自啟動模式。
作業系統:Linux
資料庫:Oracle 10g
1、vi /etc/oratab
找到bisal:/opt/oracle/102:N,將N設為Y。
檔案的注釋:
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
可以看到這裡$ORACLE_SID是bisal,$ORACLE_HOME是/opt/oracle/102。
設定為Y時,允許執行個體自啟動,當設定為N時,則不允許自啟動。
這個檔案裡的配置僅僅起一個開關的作用,其並不會具體的執行啟動和關閉,具體的操作由$ORACLE_HOME/bin/dbstart和dbshut 指令碼來實現。 這2個指令碼在執行時會檢查/etc/oratab 檔案裡的配置,為Y時才能繼續執行。
2、將lsnrctl start和dbstart添加到rc.local檔案中:
vi /etc/rc.d/rc.local
su oracle -lc "/opt/oracle/102/bin/lsnrctl start"
su oracle -lc /opt/oracle/102/bin/dbstart
檔案:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
此處也可以使用自己定義的指令碼作為啟動指令碼。
然後重啟伺服器,就可以看到監聽和執行個體都可以自動啟動了。