Oracle監聽的靜態註冊和動態註冊

靜態註冊:經過解析listene.ora文件數據庫

動態註冊:由PMON進程動態註冊至監聽中oracle

在沒有listener.ora配置文件的狀況下,若是啓動監聽,則監聽爲動態註冊。用圖形化netca建立的監聽,默認也爲動態註冊tcp

1.靜態註冊工具

listener.ora文件,監聽的配置文件,靜態註冊讀取該文件,動態註冊,沒必要要this

能夠經過netca工具建立,也能夠手動編輯。典型的listener.ora文件內容:spa

LISTENER_PHAMR =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = phamrdb1-vip)(PORT = 1521))
  )xml

 

SID_LIST_LISTENER_PHALR =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = phalr)
      (ORACLE_HOME = /oracle/product/11.2.0)
      (SID_NAME = phalr)
    )
  )進程

listener.ora文件兩大模塊:ip

LISTENER模塊:監聽名字、鏈接協議、監聽主機、監聽端口等基本配置信息ci

SID_LIST_LISTENER模塊:配置監聽的靜態註冊特性,包含數據庫服務名、ORACLE_HOME、實例名等信息。

注意:SID_NAME,就是數據庫實例名,在Linux環境大小寫敏感

GLOBAL_DBNAME就是數據庫服務名,能夠省略,默認和SID_NAME保持一致,也能夠不一致。

ORACLE_HOME,默認和$ORACLE_HOME環境變量保持一致。Windows,該參數無效,取自注冊表。

靜態註冊,監聽不知道實例的具體狀態,因此監聽啓動之初查看實例信息,其狀態信息顯示爲UNKNOWN.例如:

oracle@phamrdb1: /home/oracle> lsnrctl status LISTENER_PHAMR

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 17:17:37

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=phamrdb1-vip)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER_PHAMR
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                01-OCT-2016 14:12:51
Uptime                    47 days 3 hr. 4 min. 45 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /oracle/diag/tnslsnr/phamrdb1/listener_phamr/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.178.1.64)(PORT=1521)))
Services Summary...
Service "phamr" has 1 instance(s).     監聽狀態中的服務名
  Instance "phamr", status UNKNOWN, has 1 handler(s) for this service...  監聽狀態中的實例名
The command completed successfully

2,動態註冊
在動態註冊監聽的環境中,listener.ora文件能夠不包括當前數據庫的實例信息,因此這個文件沒必要要。

實例啓動時,會由Oracle PMON進程將數據庫實例信息動態註冊至監聽上。

當Oracle實例關閉時,會再次由PMON進程自動從監聽裏面撤銷當前實例信息。

因此,要實現動態註冊,數據庫的實例至少要處於nomount狀態

監聽動態註冊時的實例狀態:來自PMON進程動態註冊時的實例狀態,通常有3種狀態:READY、BLOCKED和RESTRICED

READY:表示數據庫實例已經處於mount或者open狀態,能夠接受客戶端鏈接

BLOCKED:表示數據庫實例還處於nomount狀態或者該實例類型爲ASM實例,不接受客戶端鏈接,若是這時候客戶端去連

               接數據庫會報ora-12528錯誤

RESTRICED:表示數據庫處於RESTRICED模式,不接受普通權限的遠程客戶端鏈接,若是這時候客戶端去鏈接數據庫會報

                  ora-12526錯誤

oracle@fsdata: /oracle/product/11.2.0/network/admin> lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 16:01:43

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                17-NOV-2016 15:57:23
Uptime                    0 days 0 hr. 4 min. 19 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /oracle/diag/tnslsnr/fsdata/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fsdata)(PORT=1521)))
Services Summary...
Service "FSDATA" has 1 instance(s).
  Instance "FSDATA", status READY, has 1 handler(s) for this service...
Service "FSDATAXDB" has 1 instance(s).
  Instance "FSDATA", status READY, has 1 handler(s) for this service...
The command completed successfully

oracle@fsdata: /oracle/product/11.2.0/network/admin> lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 15:58:47

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                17-NOV-2016 15:57:23
Uptime                    0 days 0 hr. 1 min. 23 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /oracle/diag/tnslsnr/fsdata/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fsdata)(PORT=1521)))
Services Summary...
Service "FSDATA" has 1 instance(s).
  Instance "FSDATA", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

實例既能夠動態註冊,同時靜態註冊,狀態分別顯示爲READYUNKNOWN

oracle@fsdata: /oracle/product/11.2.0/network/admin> lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-NOV-2016 17:50:14

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=fsdata)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                17-NOV-2016 15:57:23
Uptime                    0 days 1 hr. 52 min. 50 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /oracle/diag/tnslsnr/fsdata/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fsdata)(PORT=1521)))
Services Summary...
Service "FSDATA" has 2 instance(s).
  Instance "FSDATA", status UNKNOWN, has 1 handler(s) for this service...
  Instance "FSDATA", status READY, has 1 handler(s) for this service...
Service "FSDATAXDB" has 1 instance(s).
  Instance "FSDATA", status READY, has 1 handler(s) for this service...
The command completed successfully

3.監聽的經常使用命令

lsnrctl start [listener_name]

lsnrctl stop [listener_name]

lsnrctl status [listener_name]

lsnrctl service [listener_name]

lsnrctl reload [listener_name]

4.監聽的別名

監聽默認名字是LISTENER,能夠配置別名

oracle@fsdata: /dump> ps -ef | grep tnslsnr | grep  -v grep
oracle   29598     1  0 15:57 ?        00:00:00 /oracle/product/11.2.0/bin/tnslsnr LISTENER -inherit

oracle@phamrdb1: /home/oracle> ps -ef | grep tnslsnr| grep -v grep oracle   38300     1  0 Oct01 ?        06:21:54 /oracle/product/11.2.0/bin/tnslsnr LISTENER_PHAMR –inherit

相關文章
相關標籤/搜索