<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[查看apache连接数---timewait过多]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Sat, 25 Sep 2010 01:53:22 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	<div class="code">netstat -na&#124;grep ESTABLISHED&#124;awk &#039;&#123;print $5&#125;&#039;&#124;awk -F: &#039;&#123;print $1&#125;&#039;&#124;sort&#124;uniq -c&#124;sort -r +0n</div><br/><br/><div class="code">netstat -na&#124;grep SYN&#124;awk &#039;&#123;print $5&#125;&#039;&#124;awk -F: &#039;&#123;print $1&#125;&#039;&#124;sort&#124;uniq -c&#124;sort -r +0n</div><br/><br/>Onecent:~ # netstat -an &#124; grep 80 &#124; awk &#039;&#123;print $6&#125;&#039; &#124; sort &#124; uniq -c &#124; sort -rn<br/>&nbsp;&nbsp;&nbsp;&nbsp;681 TIME_WAIT<br/>&nbsp;&nbsp;&nbsp;&nbsp;122 ESTABLISHED<br/>&nbsp;&nbsp;&nbsp;&nbsp;107 FIN_WAIT2<br/>&nbsp;&nbsp;&nbsp;&nbsp; 44 FIN_WAIT1<br/>&nbsp;&nbsp;&nbsp;&nbsp; 14 SYN_SENT<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 LAST_ACK<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 SYN_RECV<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 LISTEN<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 CLOSING<br/><br/>linux可以查看多少人连接了80端口:<br/><div class="code">Onecent:~ # netstat -na&nbsp;&nbsp;&#124; grep &quot;:80&quot; &#124; wc <br/>&nbsp;&nbsp; 1074&nbsp;&nbsp;&nbsp;&nbsp;6444&nbsp;&nbsp; 86994</div><br/><br/><div class="code">Onecent:~ # netstat -atlunp&#124;grep 80&#124;grep TIME_WAIT&#124;wc<br/>&nbsp;&nbsp;&nbsp;&nbsp;787&nbsp;&nbsp;&nbsp;&nbsp;5509&nbsp;&nbsp; 79487</div><br/><br/><div class="code">Oncecent:~ # netstat -atlunp&#124;grep 80&#124;wc<br/>&nbsp;&nbsp; 1030&nbsp;&nbsp;&nbsp;&nbsp;7210&nbsp;&nbsp;104030</div><br/><br/>线程数：<br/><div class="code">Onecent:/usr/local/apache2/conf # ps -ef &#124;grep httpd &#124;wc -l <br/>360</div><br/><br/><br/>工作模式查看：<br/><div class="code">Onecent:/usr/local/apache2/conf # /usr/local/apache2/bin/httpd -l<br/>Compiled in modules:<br/>&nbsp;&nbsp;core.c<br/>&nbsp;&nbsp;mod_access.c<br/>&nbsp;&nbsp;mod_auth.c<br/>&nbsp;&nbsp;mod_cache.c<br/>&nbsp;&nbsp;mod_disk_cache.c<br/>&nbsp;&nbsp;mod_mem_cache.c<br/>&nbsp;&nbsp;mod_include.c<br/>&nbsp;&nbsp;mod_deflate.c<br/>&nbsp;&nbsp;mod_log_config.c<br/>&nbsp;&nbsp;mod_env.c<br/>&nbsp;&nbsp;mod_expires.c<br/>&nbsp;&nbsp;mod_setenvif.c<br/>&nbsp;&nbsp;prefork.c<br/>&nbsp;&nbsp;http_core.c<br/>&nbsp;&nbsp;mod_mime.c<br/>&nbsp;&nbsp;mod_status.c<br/>&nbsp;&nbsp;mod_autoindex.c<br/>&nbsp;&nbsp;mod_asis.c<br/>&nbsp;&nbsp;mod_cgi.c<br/>&nbsp;&nbsp;mod_negotiation.c<br/>&nbsp;&nbsp;mod_dir.c<br/>&nbsp;&nbsp;mod_imap.c<br/>&nbsp;&nbsp;mod_actions.c<br/>&nbsp;&nbsp;mod_userdir.c<br/>&nbsp;&nbsp;mod_alias.c<br/>&nbsp;&nbsp;mod_rewrite.c<br/>&nbsp;&nbsp;mod_so.c</div><br/><br/>注意：prefork.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //此处为mpm工作模式，也可使用worker.c模式<br/><br/><br/><div class="code">netstat -n &#124; awk &#039;/^tcp/ &#123;++S&#91;$NF&#93;&#125;;END &#123;for(a in S) print a, S&#91;a&#93;&#125;&#039;</div><br/><br/><br/><div class="code">Onecent:/usr/local/# netstat -n &#124; awk &#039;/^tcp/ &#123;++S&#91;$NF&#93;&#125;;END &#123;for(a in S) print a, S&#91;a&#93;&#125;&#039;<br/>LAST_ACK 3<br/>SYN_RECV 5<br/>ESTABLISHED 207<br/>FIN_WAIT1 63<br/>FIN_WAIT2 105<br/>SYN_SENT 1<br/>TIME_WAIT 912</div><br/><br/>修理修理下面的参数：<br/><div class="code">sysctl -p<br/>net.ipv4.icmp_echo_ignore_broadcasts = 1<br/>net.ipv4.conf.all.rp_filter = 1<br/>kernel.sysrq = 1<br/>net.ipv4.tcp_fin_timeout = 30<br/>net.ipv4.tcp_keepalive_time = 1200<br/>net.ipv4.tcp_syncookies = 1<br/>net.ipv4.tcp_tw_reuse = 1<br/>net.ipv4.tcp_tw_recycle = 1<br/>net.ipv4.ip_local_port_range = 2048&nbsp;&nbsp;&nbsp;&nbsp;65000<br/>net.ipv4.tcp_max_syn_backlog = 8192<br/>net.ipv4.tcp_max_tw_buckets = 5000</div><br/><br/><br/><br/>修改：<br/><br/>1, sysctl命令的作用<br/>&nbsp;&nbsp;&nbsp;&nbsp; 在运行时配置内核参数<br/><br/>2,用法举例:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-w 用此选项来改变一个sysctl设置<br/>&nbsp;&nbsp;&nbsp;&nbsp; 例:sysctl -w net.ipv4.ip_forward=1<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp; -p&nbsp;&nbsp; 载入sysctl配置文件<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如-p后未指定路径，则载入 /etc/sysctl.conf<br/>&nbsp;&nbsp;&nbsp;&nbsp; 例: sysctl -p /etc/sysctl.conf<br/><br/>3,修改/etc/sysctl.conf可以保存设置在机器重启后仍然有效<br/>&nbsp;&nbsp;&nbsp;&nbsp;例如:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vi /etc/sysctl.conf<br/>&nbsp;&nbsp; 修改:&nbsp;&nbsp;net.ipv4.ip_forward=0的值为1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 作用:打开数据包的转发功能<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;如何使修改马上生效?<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sysctl -p /etc/sysctl.conf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// 作用:重新载入/etc/sysctl.conf文件 <br/><br/>整个张宴的nginx的配置，如下，可以参考：<br/>优化Linux内核参数<br/>vi /etc/sysctl.conf<br/><br/>　　在末尾增加以下内容：<br/>引用<br/>net.ipv4.tcp_fin_timeout = 30<br/>net.ipv4.tcp_keepalive_time = 300<br/>net.ipv4.tcp_syncookies = 1<br/>net.ipv4.tcp_tw_reuse = 1<br/>net.ipv4.tcp_tw_recycle = 1<br/>net.ipv4.ip_local_port_range = 5000&nbsp;&nbsp;&nbsp;&nbsp;65000<br/>　　使配置立即生效：<br/>/sbin/sysctl -p
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] 查看apache连接数---timewait过多]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>