<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[阿Tim日志]]></title> 
<link>https://atim.cn/index.php</link> 
<description><![CDATA[专业的php开发者.开发团队的带队人]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[阿Tim日志]]></copyright>
<item>
<link>https://atim.cn/post/1064/</link>
<title><![CDATA[Too many connectionsConnection closed by foreign host 解决方法]]></title> 
<author>bkkkd &lt;partybase@gmail.com&gt;</author>
<category><![CDATA[开发应用]]></category>
<pubDate>Wed, 19 Jun 2013 14:49:57 +0000</pubDate> 
<guid>https://atim.cn/post/1064/</guid> 
<description>
<![CDATA[ 
	今日在服务器的mysql出现了”Too many connectionsConnection closed by foreign host “错误。这个错误之前在测试机也出现过，当时没有留意，只是将测试机中的web服务器定时重启，以解决该问题。而今日出现的在外网的服务器，不能如些操作。可惜在baidu上根据没有找到有用的资料。都是一些小白写的文章。<br/><br/>后来经朋友分析，可能是iptables引起。由于linux下的iptables都是使用ip_conntrack进行跟踪，所有的进出数据包都会记录在连接跟踪表中，包括tcp，udp，icmp等，一旦连接跟踪表被填满以后，就会发生丢包，导致网络不稳定。<br/><br/>而我这一次刚好是由于昨天晚上增加了新的iptables条件，在大量访问下，出现了掉包的情况。引起mysql错误，而最后mysql由于没有获取到正确的连接，而完全没有占用cpu.<br/><br/>解决方法：<br/>首先需要先加载ip_conntrack 模块，再通过以下接口进行调整，例如：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">modprobe&nbsp;&nbsp;ip_conntrack<br/>sysctl –w net.ipv4.netfilter.ip_conntrack_max = 655360</div></div><br/><br/>如果需要支持655360条跟踪记录的话，只需要将hash bucket设置为81920即可：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">modprobe&nbsp;&nbsp;ip_conntrack&nbsp;&nbsp;hashsize=81920</div></div><br/><br/>或者添加到 /etc/modprobe.conf 配置文件中：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">options ip_conntrack&nbsp;&nbsp;hashsize=81920</div></div><br/><br/>通过这种方式就可以做到在ip_conntrack模块被加载时就设置好连接跟踪表的大小。<br/><br/>参考：http://bkeep.blog.163.com/blog/static/12341429020120303114594/
]]>
</description>
</item><item>
<link>https://atim.cn/post/1064/#blogcomment6229</link>
<title><![CDATA[[评论] Too many connectionsConnection closed by foreign host 解决方法]]></title> 
<author>史咸匹妾 &lt;g7rmnqlz@expressemail.org&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 17 Sep 2013 02:46:35 +0000</pubDate> 
<guid>https://atim.cn/post/1064/#blogcomment6229</guid> 
<description>
<![CDATA[ 
	不是很明白啊。
]]>
</description>
</item>
</channel>
</rss>