linux 异常

1. NoRouteToHostException异常问题的原因及解决 (转自:http://performtest163.blog.163.com/blog/static/14007696420115295119462)

    1). 根据TCP/IP协议,连接断开之后,端口不会立刻被释放,而是处于TIME_WAIT状态,等待两分钟半后,才会被释放掉,才能被新连接使用。

         而性能测试并发了3W连接,在3W连接因超时而关闭后,grinder又迅速请求3W连接,这时,已被占用的端口号未被释放,部分新建连接因为

         无法分配到端口号而失败。

     2). 通过配置TCP_TW_REUSE参数,来释放TIME_WAIT状态的端口号给新连接使用

          TCP_TW_REUSE

          This allows reusing sockets in TIME_WAIT state for new connections when it is safe from protocol viewpoint. Default value is

          0 (disabled). It is generally a safer alternative to tcp_tw_recycle 

          参考资料:http://www.speedguide.net/articles/linux-tweaking-121

      3). 在/etc/sysctl.conf中设置参数:net.ipv4.tcp_tw_reuse=1 。设置参数后,重新测试,不再出现异常情况。

posted @ 2015-03-13 19:19  Jtianlin  阅读(365)  评论(0编辑  收藏  举报