(一)参数说明:
(1). rate_limit参数从9.2.0.8引入,可以用来控制连接风暴。rate_limit后面跟的参数是允许每秒连接的个数,配置完成后,需要stop/start listener生效。如下:
1 2 3 4 5 6 7 8 9 |
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.sample.com)(PORT = 1521)(RATE_LIMIT=5)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.sample.com)(PORT = 1522)) ) ) |
上面的配置表示1521端口只允许每秒5个连接,而1522端口是没有限制的。
配置以后,在listener.log中,如果有超过设置的连接数,会报错tns-1158:
在11:42:24这个时刻,可以看到最多5个连接,超出的就报错tns-1158了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
15-MAY-2010 11:42:24 * establish * 1158 TNS-01158: Internal connection limit reached, preventing dispatcher from connecting 15-MAY-2010 11:42:24 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60340)) * establish * S111W6 * 0 15-MAY-2010 11:42:24 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60341)) * establish * S111W6 * 0 15-MAY-2010 11:42:24 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60342)) * establish * S111W6 * 0 15-MAY-2010 11:42:24 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60344)) * establish * S111W6 * 0 15-MAY-2010 11:42:24 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60343)) * establish * S111W6 * 0 15-MAY-2010 11:42:25 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60345)) * establish * S111W6 * 0 15-MAY-2010 11:42:25 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60346)) * establish * S111W6 * 0 15-MAY-2010 11:42:25 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60347)) * establish * S111W6 * 0 15-MAY-2010 11:42:25 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60349)) * establish * S111W6 * 0 15-MAY-2010 11:42:25 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=S111W6)(CID=(PROGRAM=sqlplus)(HOST=sample.com)(USER=grdbms))) * (ADDRESS=(PROTOCOL=tcp)(HOST=sample.com)(PORT=60348)) * establish * S111W6 * 0 |
(2). 除了上面的这种配置,还有另外一种配置方式,设置connection_rate_listener
1 2 3 4 5 6 7 8 9 10 |
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.sample.com)(PORT = 1521)(RATE_LIMIT=YES)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host.sample.com)(PORT = 1522)(RATE_LIMIT=YES)) ) ) CONNECTION_RATE_LISTENER=10 |
上述配置表示1521和1522端口,都受到rate_limit的限制,每秒最多连接数是10个。
(二)已知问题
(1). Bug 8529537 : ALL NEW CONNECTIONS ARE REFUSED BY ORA-12547 AFTER TNS-01158 IN LISTENER.LOG
描述:当达到设置rate_limit的最大值之后,报错tns-1158,但是后续新的连接无法连接了。
受影响版本:11.2.0.1、11.1.0.7、10.2.0.4
Fix版本:11.2.0.2 、 12.1
(2). Bug 16409926:LISTENER MEMORY LEAK IF RATE_LIMIT IS USED AND ENFORCED FREQUENTLY
描述:设置rate_limit之后,过来的连接需要花费较长的时间才能建立,tnsping的响应也需要较长时间,重启listener之后可以解决问题,但是不久之后问题重现。
受影响版本:11.2
Fix版本:11.2.0.4 and 12.1.0.2,或者应用patch 16409926。
(三)相关文档:
How To Control the Amount of Connections Handled by the TNS Listener (Doc ID 443744.1)
TNS Listener Hang Every 49.X Days (Doc ID 1357676.1)
11gR2 Listener With RATE_LIMIT Set: Slow Connect Time and Tnsping Response Time High with TNS-1158 Error (Doc ID 1568591.1)
ORA-12547 & TNS-01158: Listener Stops Allowing Connections When Rate_Limit Feature is in Place (Doc ID 1085546.1)