linux下資料庫執行個體監聽開機自啟動設定

來源:互聯網
上載者:User

標籤:linux   資料庫   開機自啟動   

linux下資料庫執行個體監聽開機自啟動設定

2016/5/16 zhanky

指令碼介紹

在開始之前,我們先介紹一下幾個會用到的指令碼。

oratab

oratab檔案是在建立資料庫執行個體時建立的,在安裝時使用root使用者執行root.sh指令碼後得到。(如果忘記也可以直接手動建立。)

在$ORACLE_HOME/bin目錄下的$ORACLE_HOME/bin/dbstart和$ORACLE_HOME/bin/dbshut需要調用/etc/oratab檔案,如果不存在,dbstart和dbshut將失敗,報錯資訊為/etc/oratab" is notaccessible。

oratab的格式為: ORACLE_SID:ORACLE_HOME:AUTO

如 果需要自動啟動資料庫,則將AUTO設為Y,在調用dbstart命令才生效。dbstart根據/etc/oratab中的配置來啟動相應的資料庫,選 項只是能不能用$ORACLE_HOME/bin/dbstart和$ORACLE_HOME/bin/dbshut來啟動和關閉資料庫的開關。

如果不用dbstart指令碼啟動資料庫,而是用自己的指令碼來啟動,根本不需要oratab檔案。

 

dbstart

dbstart是安裝資料庫時內建的啟動資料庫執行個體的指令碼,預設存放在$oracle_home/bin下。在這裡我們通過設定系統開機自動執行dbstart指令檔來實現,開機自動啟動資料執行個體。

 

lsnrctl

lsnrctl是安裝資料庫時內建的啟動資料庫監聽的指令碼,預設存放在$oracle_home/bin下。在這裡我們通過設定系統開機自動執行lsnrctl指令檔來實現,開機自動啟動資料監聽

 

rc.local

rc.local系統內建的是開機啟動程式指令碼,預設存放在/etc/rc.d下。我們通過在rc.local指令碼中添加執行啟動資料庫和啟動監聽的指令碼來實現開機自動開啟資料庫執行個體和監聽。

 

測試介紹

系統版本:linuxredhat 5.4 x64

資料庫版本:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

執行個體名:test

ORACLE_HOME:/u01/app/oracle/product/11.2.0/dbhome_1



測試步驟

1、修改/oratab

因為我這邊環境中沒有oratab所以手動建立

[[email protected] /]$  vi /etc/oratab 

[[email protected] /]$ cat /etc/oratab

test:/u01/app/oracle/product/11.2.0/dbhome_1:Y

 

2、編輯/rc.local

標紅地方為新加的內容。

第一條為:用oracle使用者登入,運行lsnrctl start 指令碼啟用監聽。

第二條為:用oracle使用者登入,運行dbstart啟動資料庫

[[email protected] /]$ vi /etc/rc.d/rc.local 

[[email protected] /]$ cat /etc/rc.d/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 "/u01/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start"

su - oracle -c "/u01/app/oracle/product/11.2.0/dbhome_1/bin/dbstart startup"

[[email protected] /]$ ~

 

3、測實驗證,重啟資料庫即可。

然後就完成了資料庫執行個體和監聽的開機自啟動了。

 

 

 


本文出自 “湛康穎” 部落格,請務必保留此出處http://zhanky.blog.51cto.com/7154288/1773975

linux下資料庫執行個體監聽開機自啟動設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.