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

張衝andy發表於2017-08-30

靜態註冊:透過解析listene.ora檔案

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

在沒有listener.ora配置檔案的情況下,如果啟動監聽,則監聽為動態註冊。用圖形化netca建立的監聽,預設也為動態註冊

1.靜態註冊

listener.ora檔案,監聽的配置檔案,靜態註冊讀取該檔案,動態註冊,不必要

可以透過netca工具建立,也可以手動編輯。典型的listener.ora檔案內容:

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

 

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

listener.ora檔案兩大模組:

LISTENER模組:監聽名字、連線協議、監聽主機、監聽埠等基本配置資訊

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2144333/,如需轉載,請註明出處,否則將追究法律責任。

相關文章