TNS-01106: "Listener using listener name %s has already been started"

最近在做HACMP双机互备切换测试的时候,发现一个问题:
    A节点的listener端口为1521 ,B节点的listener端口为1522,为什么两个节点的监听要用不同的端口号?
    当时AB机使用不同端口是基于如下考虑:
    HACMP的切换数据库的过程中,希望同时控制监听的启动和停止,如果两个数据库使用同一个监听,考虑如下情况

  1. 监听在A机和B都正常运行在1521
  2. A机故障,db1切换到B机,先关闭A机的监听,文件系统切换到B机,db1在B机启动,启动监听,提示端口已被占用,可以忽略,因为A的实例会动态注册到可用的listener中去。
  3. A机修复,db1会优先切换回A机,如果脚本中这时关闭B机监听,虽然不会影响B机已经连接的客户端,但是如果B机有新客户端连接,将不能连接到B机的数据库。

     问题:为什么在一个节点上不能同时起两个同一端口的listener呢?(这个问题困惑我好久了,就连做梦都在问为什么?)
     回答:其实不光是不能同时起动端口相同的listener,在listener.ora文件中,同一个KEY值的listener也是不可以同时启动的,就类似于是listener的唯一标识。即IPC addresses(KEY) or TCP port numbers are not duplicated.

在考虑这个问题的过程中,做了一些有关listener的实验,在这里与大家分享

1. 一个端口的listener可以注册多个实例
   (备注:这个当然了,比如我们在一个节点上安装多个实例)
   e.g.
LSNRCTL> status
   正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.15.99)(PORT=1521)))
   LISTENER 的 STATUS
   ------------------------
   别名                      LISTENER
   版本                      TNSLSNR for 32-bit Windows: Version 9.2.0.1.0 - Produc
   tion
   启动日期                  08-6月 -2009 09:17:22
   正常运行时间              4 天 0 小时 25 分 6 秒
   跟踪级别                  off
   安全性                    OFF
   SNMP                      OFF
   监听器参数文件          d:\oracle\network\admin\listener.ora
   监听器日志文件          d:\oracle\network\log\listener.log
   监听端点概要...
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.15.99)(PORT=1521)))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=leiz)(PORT=8080))(Presentation=HTTP)
   (Session=RAW))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=leiz)(PORT=2100))(Presentation=FTP)(
   Session=RAW))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=leiz)(PORT=8080))(Presentation=HTTP)
   (Session=RAW))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=leiz)(PORT=2100))(Presentation=FTP)(
   Session=RAW))
   服务摘要..
   服务 "PLSExtProc" 包含 1 个例程。
     例程 "PLSExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
   服务 "leiz" 包含 2 个例程。/*实例LEIZ*/
     例程 "leiz", 状态 UNKNOWN, 包含此服务的 1 个处理程序.../*静态注册*/
     例程 "leiz", 状态 READY, 包含此服务的 1 个处理程序.../*动态注册*/
   服务 "leiz2" 包含 2 个例程。/*实例LEIZ2*/
     例程 "leiz2", 状态 UNKNOWN, 包含此服务的 1 个处理程序.../*静态注册*/
     例程 "leiz2", 状态 READY, 包含此服务的 1 个处理程序.../*动态注册*/
   服务 "leiz2XDB" 包含 1 个例程。
     例程 "leiz2", 状态 READY, 包含此服务的 1 个处理程序...
   服务 "leizXDB" 包含 1 个例程。
     例程 "leiz", 状态 READY, 包含此服务的 1 个处理程序...
   命令执行成功

2. 一个实例可以同时注册到多个不同端口的listener去
    (备注:这个也没问题,比如一个实例注册到多个不同端口的listener中)
   e.g.
 LSNRCTL> status listener
   正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.15.99)(PORT=1521)))
   LISTENER 的 STATUS
   ------------------------
   别名                      LISTENER
   版本                      TNSLSNR for 32-bit Windows: Version 9.2.0.1.0 - Produc
   tion
   启动日期                  08-6月 -2009 09:17:22
   正常运行时间              4 天 0 小时 13 分 14 秒
   跟踪级别                  off
   安全性                    OFF
   SNMP                      OFF
   监听器参数文件          d:\oracle\network\admin\listener.ora
   监听器日志文件          d:\oracle\network\log\listener.log
   监听端点概要...
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.15.99)(PORT=1521)))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC0ipc)))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=leiz)(PORT=8080))(Presentation=HTTP)
   (Session=RAW))
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=leiz)(PORT=2100))(Presentation=FTP)(
   Session=RAW))
   服务摘要..
   服务 "PLSExtProc" 包含 1 个例程。
     例程 "PLSExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
   服务 "leiz" 包含 2 个例程。
     例程 "leiz", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
     例程 "leiz", 状态 READY, 包含此服务的 1 个处理程序...
   服务 "leizXDB" 包含 1 个例程。
     例程 "leiz", 状态 READY, 包含此服务的 1 个处理程序...
   命令执行成功
   
   
   LSNRCTL> status listener3
   正在连接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.15.99)(PORT=1522)))
   LISTENER 的 STATUS
   ------------------------
   别名                      LISTENER3
   版本                      TNSLSNR for 32-bit Windows: Version 9.2.0.1.0 - Produc
   tion
   启动日期                  08-6月 -2009 09:17:22
   正常运行时间              4 天 0 小时 25 分 32 秒
   跟踪级别                  off
   安全性                    OFF
   SNMP                      OFF
   监听器参数文件          d:\oracle\network\admin\listener.ora
   监听器日志文件          d:\oracle\network\log\listener3.log
   监听端点概要...
     (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.15.99)(PORT=1522)))
   服务摘要..
   服务 "PLSExtProc" 包含 1 个例程。
     例程 "PLSExtProc", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
   服务 "leiz" 包含 1 个例程。
     例程 "leiz", 状态 UNKNOWN, 包含此服务的 1 个处理程序...
   命令执行成功

3. 一个节点不可以同时启动同样 IPC keys 或者同样 listener port number的listener
   即Verify IPC addresses or TCP port numbers are not duplicated
  
   a. 一个节点可以启动多个不同端口的listener
   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_1522 =
       (SID_LIST =
         (SID_DESC =
           (SID_NAME = PLSExtProc)
           (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
           (PROGRAM = extproc)
         )
         (SID_DESC =
           (SID_NAME = devdb1)
           (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
         )
       )
       一个节点可以启动多个不同端口的listener
       LSNRCTL> start listener_1521
       LSNRCTL> start listener_1522
      
       LSNRCTL> status listener_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                17-JUN-2009 21:41:39
           Uptime                    0 days 0 hr. 1 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 "+ASM" has 1 instance(s).
             Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
           Service "+ASM_XPT" has 1 instance(s).
             Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service...
           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
          
           LSNRCTL> status listener_1522
           Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1522)))
           STATUS of the LISTENER
           ------------------------
           Alias                     listener_1522
           Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
           Start Date                17-JUN-2009 21:41:48
           Uptime                    0 days 0 hr. 0 min. 55 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_1522.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...
           Service "devdb1" has 1 instance(s).
             Instance "devdb1", status UNKNOWN, has 1 handler(s) for this service...
           The command completed successfully
           
           
           LSNRCTL> stop listener_1521                                                         
           Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1521)))
           The command completed successfully                                                  
           LSNRCTL> stop listener_1522                                                         
           Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1522)))
           The command completed successfully         
          
           b. 一个节点不可以同时启动同样 listener port number的listener
          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 = 1522))
               )
             )
           
           SID_LIST_LISTENER_1522 =
             (SID_LIST =
               (SID_DESC =
                 (SID_NAME = PLSExtProc)
                 (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
                 (PROGRAM = extproc)
               )
               (SID_DESC =
                 (SID_NAME = devdb1)
                 (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
               )
             )
             一个节点不可以同时启动同样 listener port number的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=1522)))
             Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1522)))
             STATUS of the LISTENER
             ------------------------
             Alias                     listener_1521
             Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
             Start Date                17-JUN-2009 21:46:12
             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=1522)))
             The listener supports no services
             The command completed successfully
             LSNRCTL> start listener_1522
             TNS-01106: Listener using listener name listener_1521 has already been started
            
             c.一个节点不可以同时启动同样 IPC keys 的listener
             e.g.
[oracle@rac1 admin]$ more listener.ora
             LISTENER_1522 =
               (DESCRIPTION_LIST =
                 (DESCRIPTION =
                   (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1522))
               (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
                )   
               )
              
             
             LISTENER_1521 =
               (DESCRIPTION_LIST =
                 (DESCRIPTION =
                   (ADDRESS = (PROTOCOL = TCP)(HOST = rac1.domain.com)(PORT = 1521))
                 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
               )
               )
             
             SID_LIST_LISTENER_1522 =
               (SID_LIST =
                 (SID_DESC =
                   (SID_NAME = PLSExtProc)
                   (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
                   (PROGRAM = extproc)
                 )
                 (SID_DESC =
                   (SID_NAME = devdb1)
                   (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
                 )
               )
             一个节点不可以同时启动同样 IPC keys 的listener
             LSNRCTL> start listener_1522
             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_1522.log
             Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1522)))
             Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
             Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1.domain.com)(PORT=1522)))
             STATUS of the LISTENER
             ------------------------
             Alias                     listener_1522
             Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
             Start Date                17-JUN-2009 22:09:40
             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_1522.log
             Listening Endpoints Summary...
               (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.domain.com)(PORT=1522)))
               (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
             Services Summary...
             Service "PLSExtProc" has 1 instance(s).
               Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
             Service "devdb1" has 1 instance(s).
               Instance "devdb1", status UNKNOWN, has 1 handler(s) for this service...
             The command completed successfully

             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)))
             Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
             TNS-12542: TNS:address already in use
              TNS-12560: TNS:protocol adapter error
               TNS-00512: Address already in use
                Linux Error: 98: Address already in use
              
             Listener failed to start. See the error message(s) above...
            
                                        
Symptoms
    There are two or more oracle instances in two seperate oracle homes. Both listeners need to run concurrently. When starting a second listener, a TNS-01106 "Listener using listener name %s has already been started" error is received.
Cause
    A second listener process attempted to start with the same IPC key, port address as that of an listener already running.
Solution
    Verify IPC addresses or TCP port numbers are not duplicated

#listener.ora file for the first listener
LISTENER =
 (ADDRESS_LIST =
   (ADDRESS= (PROTOCOL= IPC)(KEY= ORCL))
   (ADDRESS= (PROTOCOL= IPC)(KEY= PNPKEY))
   (ADDRESS= (PROTOCOL= TCP)(Host= jumbo)(Port= 1521))
 )
#listener.ora file for the second listener
LISTENER =
 (ADDRESS_LIST =
   (ADDRESS= (PROTOCOL= IPC)(KEY= ORCL))
   (ADDRESS= (PROTOCOL= IPC)(KEY= PNPKEY))
   (ADDRESS= (PROTOCOL= TCP)(Host= jumbo)(Port= 1521))
 )

The listener.ora file for the 2nd listener example must have different IPC keys from the first listener.ora file and the port number for the TCP address must be different between any other listener definitions.
Implement the changes and restart the listeners

参考文献:

1.Subject:  TNS-01106: "Listener using listener name %s has already been started"
  Doc ID:  102430.1 Type:  PROBLEM
  Modified Date :  22-JAN-2008 Status:  PUBLISHED

2.listener的静态注册与动态注册详述 
   http://space.itpub.net/9252210/viewspace-580699

你可能感兴趣的:(TNS-01106: "Listener using listener name %s has already been started")