oracle監聽的動態注冊和靜態注冊


參考資料:


https://blog.csdn.net/tianlesoftware/article/details/5543166

https://www.cnblogs.com/guilingyang/p/6074867.html

 現象1:


1、動態注冊

參數文件中指定service_names(多個服務名vmdb,sn01,sn02),8i以后數據庫實例啟動后,會根據參數文件的service_names以及instance_name動態注冊到監聽器:

 1 SQL> show parameter service_names;
 2 
 3 NAME                     TYPE     VALUE
 4 ------------------------------------ ----------- ------------------------------
 5 service_names                 string     vmdb,sn01,sn02
 6 SQL> show parameter instance_name;
 7 
 8 NAME                     TYPE     VALUE
 9 ------------------------------------ ----------- ------------------------------
10 instance_name                 string     vmdb

 

2、靜態注冊

實例啟動時讀取文件$ORACLE_HOME/network/admin/listener.ora文件的配置,將實例和服務注冊到監聽程序。listener.ora文件配置如下:

 1 SID_LIST_LISTENER =
 2   (SID_LIST =
 3     (SID_DESC =
 4       (GLOBAL_DBNAME = sn03)
 5       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
 6       (SID_NAME = vmdb)
 7     )
 8   )
 9 
10 LISTENER =
11   (DESCRIPTION =
12     (ADDRESS = (PROTOCOL = TCP)(HOST = CentOS)(PORT = 1521))
13   )
14 
15 ADR_BASE_LISTENER = /u01/app/oracle

 

3、先啟動數據庫再啟動監聽

 1 SQL> startup
 2 ORACLE instance started.
 3 
 4 Total System Global Area  776646656 bytes
 5 Fixed Size            2217384 bytes
 6 Variable Size          583010904 bytes
 7 Database Buffers      188743680 bytes
 8 Redo Buffers            2674688 bytes
 9 Database mounted.
10 Database opened.
啟動數據庫
 1 [oracle@CentOS ~]$ lsnrctl start
 2 
 3 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-MAR-2018 13:03:11
 4 
 5 Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 6 
 7 TNS-01106: Listener using listener name LISTENER has already been started
 8 [oracle@CentOS ~]$ lsnrctl reload
 9 
10 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-MAR-2018 13:03:19
11 
12 Copyright (c) 1991, 2009, Oracle.  All rights reserved.
13 
14 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=CentOS)(PORT=1521)))
15 The command completed successfully
16 [oracle@CentOS ~]$ lsnrctl status
17 
18 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-MAR-2018 13:03:25
19 
20 Copyright (c) 1991, 2009, Oracle.  All rights reserved.
21 
22 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=CentOS)(PORT=1521)))
23 STATUS of the LISTENER
24 ------------------------
25 Alias                     LISTENER
26 Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
27 Start Date                28-MAR-2018 13:03:08
28 Uptime                    0 days 0 hr. 0 min. 16 sec
29 Trace Level               off
30 Security                  ON: Local OS Authentication
31 SNMP                      OFF
32 Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
33 Listener Log File         /u01/app/oracle/diag/tnslsnr/CentOS/listener/alert/log.xml
34 Listening Endpoints Summary...
35   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=CentOS)(PORT=1521)))
36 Services Summary...
37 Service "sn03" has 1 instance(s).
38   Instance "vmdb", status UNKNOWN, has 1 handler(s) for this service...
39 The command completed successfully
啟動監聽器

發現監聽服務只有靜態注冊的sn03

 

4、手工注冊

 1 SQL> alter system register; 2 3 System altered. 

再次查看監聽,動態注冊成功:

 1 [oracle@CentOS ~]$ lsnrctl status
 2 
 3 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-MAR-2018 12:41:00
 4 
 5 Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 6 
 7 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=CentOS)(PORT=1521)))
 8 STATUS of the LISTENER
 9 ------------------------
10 Alias                     LISTENER
11 Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
12 Start Date                28-MAR-2018 12:40:45
13 Uptime                    0 days 0 hr. 0 min. 15 sec
14 Trace Level               off
15 Security                  ON: Local OS Authentication
16 SNMP                      OFF
17 Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
18 Listener Log File         /u01/app/oracle/diag/tnslsnr/CentOS/listener/alert/log.xml
19 Listening Endpoints Summary...
20   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=CentOS)(PORT=1521)))
21 Services Summary...
22 Service "sn01" has 1 instance(s).
23   Instance "vmdb", status READY, has 1 handler(s) for this service...
24 Service "sn02" has 1 instance(s).
25   Instance "vmdb", status READY, has 1 handler(s) for this service...
26 Service "sn03" has 1 instance(s).
27   Instance "vmdb", status UNKNOWN, has 1 handler(s) for this service...
28 Service "vmdb" has 1 instance(s).
29   Instance "vmdb", status READY, has 1 handler(s) for this service...
30 Service "vmdbXDB" has 1 instance(s).
31   Instance "vmdb", status READY, has 1 handler(s) for this service...
32 The command completed successfully
查看監聽狀態

 

動態注冊到非默認端口


如果要向非默認監聽注冊,則要修改相應系統參數。將要監聽的信息添加到tnsnames.ora文件(pmon動態注冊監聽時從tnsnames.ora文件讀取信息)。

對於專用服務器模式:

LOCAL_LISTENER=listener_alias

 

對於共享服務器模式:

DISPATCHERS="(PROTOCOL=tcp)(LISTENER=listener_alias)"

 

例如對於專用服務器模式,監聽端口1522:

1、修改listener.ora文件監聽器的監聽端口

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = CentOS)(PORT = 1522))
  )

 

 

2、修改tnsnames.ora,設置pmon動態注冊的目標端口

1 listener_alias =
2   (DESCRIPTION =
3     (ADDRESS = (PROTOCOL = TCP)(HOST = CentOS)(PORT = 1522))
4   )

 

3、修改參數LOCAL_LISTENER

alter system set local_listener=listener_alias;

 

alter system register;

 

4、查看監聽狀態

 1 [oracle@CentOS admin]$ lsnrctl status
 2 
 3 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 31-MAR-2018 06:55:42
 4 
 5 Copyright (c) 1991, 2009, Oracle.  All rights reserved.
 6 
 7 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=CentOS)(PORT=1522)))
 8 STATUS of the LISTENER
 9 ------------------------
10 Alias                     LISTENER
11 Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
12 Start Date                31-MAR-2018 06:55:14
13 Uptime                    0 days 0 hr. 0 min. 28 sec
14 Trace Level               off
15 Security                  ON: Local OS Authentication
16 SNMP                      OFF
17 Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
18 Listener Log File         /u01/app/oracle/diag/tnslsnr/CentOS/listener/alert/log.xml
19 Listening Endpoints Summary...
20   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=CentOS)(PORT=1522)))
21 Services Summary...
22 Service "sn01" has 1 instance(s).
23   Instance "vmdb", status READY, has 1 handler(s) for this service...
24 Service "sn02" has 1 instance(s).
25   Instance "vmdb", status READY, has 1 handler(s) for this service...
26 Service "sn03" has 1 instance(s).
27   Instance "vmdb", status UNKNOWN, has 1 handler(s) for this service...
28 Service "vmdb" has 1 instance(s).
29   Instance "vmdb", status READY, has 1 handler(s) for this service...
30 Service "vmdbXDB" has 1 instance(s).
31   Instance "vmdb", status READY, has 1 handler(s) for this service...
32 The command completed successfully
View Code  

 

靜態注冊的意義


//TODO 

 

總結:


與文章開頭的引用的外部文章說法有些差異:

1、動態注冊只會在PMON進程啟動時才會自動將服務注冊到監聽器(一般在啟動一分鍾內完成注冊),如果此時監聽器未啟動,則動態注冊失敗,此時如果再啟動監聽器,依然不會有動態注冊信息。

2、靜態注冊與實例是否啟動無關,啟動監聽器時會讀取listener.ora文件進行靜態注冊,此時即便數據庫未啟動,監聽狀態依然能看到靜態注冊信息。重啟監聽器也一樣,只會進行靜態注冊,所以可能導致動態注冊信息丟失。

3、動態注冊默認只注冊到默認的監聽器(名稱LISTENER,端口1521,協議TCP),否則PMON不能動態注冊listener,除非修改參數local_listener。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM