靜態注冊:通過解析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
|
實例既可以動態注冊,同時靜態注冊,狀態分別顯示為READY和UNKNOWN
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