<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">检查too many open files,一般包括2个层面:文件操作层面和socket层面。</span>
- 对于文件句柄
具体的优化方式也比较简单,在/etc/security/limits.conf 添加如下行:
* soft nofile 65535 * hard nofile 65535
然后使用sysctl -p使配置生效
- socket层面
lsof -n |awk '{print $2}'|sort|uniq -c |sort -nr|more
然后找到最多的几个进程号,使用
lsof -n |grep 22335 | more
或
lsof -p 22335
具体的命令和进程信息
2、在配置文件/etc/sysctl.conf增加如下行:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
然后执行
sysctl -p
使修改生效
观察netstat -ae |grep TIME
是否数量在不断减少