Oracle單機環境實現開機自動啟動資料庫
Windows環境和Unix環境都能夠實現Oracle資料庫的自動啟動。
Windows環境下:
實驗方法相對簡單,通過修改註冊表或用oradim命令來實現:
oradim -edit <SID> -startmode [auto|manual] -shutmode [nomal|immediate|abort]
Unix環境下:
通過資料庫內建的dbstart命令來實驗.
命令: dbstart + {ORACLE_HOME的全路徑}
原理:
1. 作業系統啟動過程中,讀取/etc/oratab檔案,判斷是否有哪些資料庫是需要自動啟動的(N代表不自動啟動,Y代表自動啟動)
ora10g:/u01/app/oracle/product/10.2.0:Y <<<<<<<<<自動啟動
catdb:/u01/app/oracle/product/10.2.0:N <<<<<<<<<不自動啟動
2. 調用dbstart命令啟動監聽器和資料庫
查看指令碼全路徑為$ORACLE_HOME/bin/dbstart,會注意到:
監聽器的啟動受環境變數ORACLE_HOME_LISTNER影響
以LINUX環境操作過程為例:
1. 如下編輯/etc/oratab檔案
[oracle@ora10g bdump]$ cat /etc/oratab
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.</span></p><p><span style="font-size:14px;"># 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.
#
#
ora10g:/u01/app/oracle/product/10.2.0:Y <<<<<<<<<<<<<<<<<<<<
catdb:/u01/app/oracle/product/10.2.0:N
注: 資料庫執行個體為ora10g,它的安裝目錄位置/u01/app/oracle/product/10.2.0,開戶自動啟動
2. 添加dbstart命令至rc.local.如下:
[oracle@ora10g bdump]$ cat /etc/rc.local
#!/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.
touch /var/lock/subsys/local
su - oracle -c "dbstart /u01/app/oracle/product/10.2.0" <<<<<<<<<<<<<<<<<<<<<全路徑根據你的實際情況來定
至此,自動啟動的環境準備完成了.可以通過dbstart +{資料庫安裝目錄全路徑}來做測試或重啟驗證了...