ITPub博客

首页 > Linux操作系统 > Linux操作系统 > how to decision which is current listener

how to decision which is current listener

原创 Linux操作系统 作者:zhanglei_itput 时间:2009-06-18 00:39:27 0 删除 编辑

how to decision which is current listener???
    最近快被listener搞死了,本以为自己已经很明白了,但是碰到问题的时候,还是无法解释清楚,做了几个实验终于清楚了。

    不知道大家是否注意过这样一个问题,当你做HACMP双机互备的时候,为了防止切换回原来节点时,停监听的动作不影响原始库中新连接的会话,所以两个节点的listener端口不能相同。但是我发现
    节点A  >lsnrctl status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     listener_1521
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                18-JUN-2009 00:52:49
Uptime                    0 days 0 hr. 0 min. 21 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener_1521.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
The listener supports no services
The command completed successfully
   

节点B >lsnrctl status
 LSNRCTL> status
 Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
 TNS-00511: No listener
 Linux Error: 111: Connection refused

问题:这是为什么?节点A1521端口,节点B1522端口,为什么他们的current不一样?那么oracle选择current listener的方法和顺序是什么??
答案:oracle默认的current_listener为(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
            那么当多个监听名字共用1521这个端口时,current_listener 为最后一次启动的listener,他们都是listener的别名。

问题:多个listener,oracle会认为who是current listener??
结论:有LISTENER参数,无论端口是否为1521,默认的current_listener=listener,与这个listener同端口的只是一个别名而已
            无LISTENER参数,找1521端口为current_listener=listener,与这个listener同端口的只是一个别名而已
            无LISTENER参数,无1521端口,默认1521端口为current_listener
  
1. listener.ora文件中有LISTENER参数,端口为1521端口
   则:current_listener = listener = listener_1521
   e.g.
   [oracle@rac1 admin]$ more listener.ora
   LISTENER_1522 =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1522))
      )   
     )
   LISTENER =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1521))
     )
     )
   LISTENER_1521 =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1521))
     )
     )
   SID_LIST_LISTENER =
     (SID_LIST =
       (SID_DESC =
         (SID_NAME = PLSExtProc)
         (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
         (PROGRAM = extproc)
       )
     )
             
    
     LSNRCTL> start
     Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...     
     TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))     
     Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1521)))
     STATUS of the LISTENER
     ------------------------
     Alias                     LISTENER
     Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     Start Date                17-JUN-2009 23:42:38
     Uptime                    0 days 0 hr. 0 min. 0 sec
     Trace Level               off
     Security                  ON: Local OS Authentication
     SNMP                      OFF
     Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening Endpoints Summary...
       (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
     Services Summary...
     Service "PLSExtProc" has 1 instance(s).
       Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
     The command completed successfully
     LSNRCTL> start listener_1521
     TNS-01106: Listener using listener name LISTENER has already been started
     备注:listener_1521和listener共用一个端口号
    
     如果先启动listener_1521,那么listener_1521是listener的一个别名,那么listener_1521为current_listener
     LSNRCTL> start listener_1521
     Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...     
     TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener_1521.log
     Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))     
     Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1521)))
     STATUS of the LISTENER
     ------------------------
     Alias                     listener_1521(listener_1521是listener的一个别名)
     Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     Start Date                17-JUN-2009 23:58:48
     Uptime                    0 days 0 hr. 0 min. 0 sec
     Trace Level               off
     Security                  ON: Local OS Authentication
     SNMP                      OFF
     Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener_1521.log
     Listening Endpoints Summary...
       (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
     The listener supports no services
     The command completed successfully
  
    

2. listener.ora文件中有LISTENER参数,端口为非1521端口
   则:current_listener=listener=listener_1522
   e.g.
   [oracle@rac1 admin]$ more listener.ora
   LISTENER_1522 =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1522))
      )   
     ) 
   LISTENER =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1522))
     )
     )   
   LISTENER_1521 =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1521))
     )
     )   
   SID_LIST_LISTENER =
     (SID_LIST =
       (SID_DESC =
         (SID_NAME = PLSExtProc)
         (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
         (PROGRAM = extproc)
       )
     )
     LSNRCTL> start
     Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...     
     TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1522)))     
     Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1522)))
     STATUS of the LISTENER
     ------------------------
     Alias                     LISTENER
     Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     Start Date                17-JUN-2009 23:48:41
     Uptime                    0 days 0 hr. 0 min. 0 sec
     Trace Level               off
     Security                  ON: Local OS Authentication
     SNMP                      OFF
     Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening Endpoints Summary...
       (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1522)))
     Services Summary...
     Service "PLSExtProc" has 1 instance(s).
       Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
     The command completed successfully
     LSNRCTL> start listener_1522
     TNS-01106: Listener using listener name LISTENER has already been started
   
     备注:如果先启动listener_1522,那么listener_1522是listener的一个别名         
    
3. listener.ora文件中没有LISTENER参数,端口为1521端口
   则:current_listener=listener=listener_1521
   e.g.
   [oracle@rac1 admin]$ more listener.ora
     LISTENER_1522 =
       (DESCRIPTION_LIST =
         (DESCRIPTION =
           (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1522))
        )   
       )
     LISTENER_1521 =
       (DESCRIPTION_LIST =
         (DESCRIPTION =
           (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1521))
       )
       )
      SID_LIST_LISTENER_1521 =
       (SID_LIST =
         (SID_DESC =
           (SID_NAME = PLSExtProc)
           (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
           (PROGRAM = extproc)
         )
       )
                                
    
     LSNRCTL> start
     Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))/*(本机默认1521端口)*/
     STATUS of the LISTENER
     ------------------------
     Alias                     LISTENER
     Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     Start Date                18-JUN-2009 00:06:46
     Uptime                    0 days 0 hr. 0 min. 6 sec
     Trace Level               off
     Security                  ON: Local OS Authentication
     SNMP                      OFF
     Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening Endpoints Summary...
       (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
     The listener supports no services
     The command completed successfully
     LSNRCTL> status
     Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
     STATUS of the LISTENER
     ------------------------
     Alias                     LISTENER
     Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     Start Date                18-JUN-2009 00:06:46
     Uptime                    0 days 0 hr. 0 min. 9 sec
     Trace Level               off
     Security                  ON: Local OS Authentication
     SNMP                      OFF
     Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening Endpoints Summary...
       (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
     The listener supports no services
     The command completed successfully
     LSNRCTL> start listener_1521
     TNS-01106: Listener using listener name LISTENER has already been started
     LSNRCTL> stop
    
     备注:如果先启动listener_1521,那么listener_1521是listener的一个别名
     LSNRCTL> start listener_1521
     Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...      
     TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener_1521.log
     Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))      
     Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1521)))
     STATUS of the LISTENER
     ------------------------
     Alias                     listener_1521
     Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     Start Date                18-JUN-2009 00:08:11
     Uptime                    0 days 0 hr. 0 min. 0 sec
     Trace Level               off
     Security                  ON: Local OS Authentication
     SNMP                      OFF
     Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener_1521.log
     Listening Endpoints Summary...
       (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
     Services Summary...
     Service "PLSExtProc" has 1 instance(s).
       Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
     The command completed successfully
 
4. listener.ora文件中没有LISTENER参数,端口中没有1521端口    
   则:current_listener=listener
   e.g.
   [oracle@rac1 admin]$ more listener.ora 
     LISTENER_1522 =
       (DESCRIPTION_LIST =
         (DESCRIPTION =
           (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1522))
        )   
       )
     LISTENER_1523 =
       (DESCRIPTION_LIST =
         (DESCRIPTION =
           (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1523))
       )
      )     
     SID_LIST_LISTENER =
       (SID_LIST =
         (SID_DESC =
           (SID_NAME = PLSExtProc)
           (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
           (PROGRAM = extproc)
         )
       ) 
     LSNRCTL> start
     Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
     TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
     Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
     STATUS of the LISTENER
     ------------------------
     Alias                     LISTENER
     Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
     Start Date                18-JUN-2009 00:16:04
     Uptime                    0 days 0 hr. 0 min. 0 sec
     Trace Level               off
     Security                  ON: Local OS Authentication
     SNMP                      OFF
     Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
     Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
     Listening Endpoints Summary...
       (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
     Services Summary...
     Service "PLSExtProc" has 1 instance(s).
       Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
     The command completed successfully
    
补充,与前面无关
5. 动态注册非1521端口的监听
   e.g.
   SQL> show parameter listener    
   NAME                                 TYPE        VALUE
   ------------------------------------ ----------- ------------------------------
   local_listener                       string
   remote_listener                      string
   SQL> alter system set local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.230.66)(PORT=1523))' scope=both sid='devdb1';
   System altered.
   SQL> show parameter listener
   NAME                                 TYPE        VALUE
   ------------------------------------ ----------- ------------------------------
   local_listener                       string      (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.230.66)(PORT=1523))
   remote_listener                      string
  
   [oracle@rac1 admin]$ more listener.ora 
   LISTENER_1521 =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1521))
      )   
     )
   LISTENER_1523 =
     (DESCRIPTION_LIST =
       (DESCRIPTION =
         (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1523))
      )
     )
   SID_LIST_LISTENER =
     (SID_LIST =
       (SID_DESC =
         (SID_NAME = PLSExtProc)
         (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
         (PROGRAM = extproc)
       )
     )
           
    
    LSNRCTL> start
    Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...    
    TNSLSNR for Linux: Version 10.2.0.4.0 - Production
    System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
    Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))    
    Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
    Start Date                18-JUN-2009 00:26:18
    Uptime                    0 days 0 hr. 0 min. 0 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1521)))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
      Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully

   
    LSNRCTL> status listener_1523
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1523)))
    STATUS of the LISTENER
    ------------------------
    Alias                     listener_1523
    Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
    Start Date                18-JUN-2009 00:16:28
    Uptime                    0 days 0 hr. 10 min. 21 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener_1523.log
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1523)))
    Services Summary...
    Service "devdb" has 1 instance(s). /*动态注册*/
      Instance "devdb1", status READY, has 1 handler(s) for this service...
    Service "devdbXDB" has 1 instance(s).
      Instance "devdb1", status READY, has 1 handler(s) for this service...
    Service "devdb_XPT" has 1 instance(s).
      Instance "devdb1", status READY, has 1 handler(s) for this service...
    The command completed successfully
    

参考文献:
 1. listener的静态注册与动态注册详述
 http://space.itpub.net/9252210/viewspace-580699 
2. TNS-01106:Listener using listener name already been started
 http://space.itpub.net/9252210/viewspace-606635

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9252210/viewspace-606650/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-02-10

  • 博文量
    400
  • 访问量
    1224691