一./etc/oratab說明
直接使用cat 查看這個檔案:
- gg1:/home/Oracle> cat /etc/oratab
- #
-
- # This file is used by ORACLEutilities. It is created by root.sh
- # and updated by the Database ConfigurationAssistant when creating
- # a database.
-
- # A colon, ':', is used as the fieldterminator. A new line terminates
- # the entry. Lines beginning with a pound sign, '#', arecomments.
- #
- # Entries are of the form:
- # $ORACLE_SID:$ORACLE_HOME:<N|Y|W>:
- #
- # The first and second fields are thesystem identifier and home
- # directory of the databaserespectively. The third filed indicates
- # to the dbstart utility that the databaseshould , "Y", or should not,
- # "N", be brought up at systemboot time.
- #
- # Multiple entries with the same$ORACLE_SID are not allowed.
- #
- #
- gg1:/u01/app/oracle/product/11.2.0.3/db_1:N
這裡是我測試環境上的檔案,在這個注釋裡面,對這個檔案講的比較清楚。/etc/oratab 由root.sh 指令碼建立,在用DBCA 建立執行個體時也會更新這個檔案。
當$ORACLE_SID:$ORACLE_HOME:<N|Y> 設定為Y時,允許執行個體自啟動,當設定為N時,則不允許自啟動。 這個檔案裡的配置僅僅起一個開關的作用,其並不會具體的執行啟動和關閉,具體的操作由$ORACLE_HOME/bin/dbstart和dbshut 指令碼來實現。 這2個指令碼在執行時會檢查/etc/oratab 檔案裡的配置,為Y時才能繼續執行。
所以設定資料庫自啟動和關閉的步驟如下:
(1) 配置/etc/oratab
(2) 修改$ORACLE_HOME/bin/dbstart和dbshut,並將其添加到/etc/rc(.local) 檔案中。
這裡是使用oracle 內建的dbstart 和dbshut指令碼,如果使用自己寫的指令碼來啟動或關閉DB 就不需要關心這個檔案的設定了。