1.linux下tcp的TIME_WAIT参数调整
netstat -na|awk ‘/^tcp/ {++S[$NF]} END {for(i in S) print i,S[i]}’
查看网络节点的tcp连接状态,如果发现系统存在大量的TIME_WAIT状态的连接,通过调整内核参数解决:
#vi /etc/sysctl.conf
编辑文件,加入以下内容,修改系統默认的TIMEOUT时间:
net.ipv4.tcp_fin_timeout = 30
修改之后,再用命令查看TIME_WAIT连接数
netstat -ae|grep “TIME_WAIT” |wc
执行以下命令让参数生效:/sbin/sysctl -p
2.linux下ulimit参数调整
查看 :ulimit -n
修改配置:
#vi /etc/security/limits.conf
# 添加如下的行
* soft nofile 65535
* hard nofile 65535
soft即是软限制,hard是硬限制。用户可以超过soft设置的值,但一定不能超过hard 的值。一般soft比hard小
noproc表示最大进程数,nofile 表示最大文件打开数
重启生效。
例:
java.io.IOException: Too many open files 此问题原因与ulimit -n有关,调大ulimit -n
There is insufficient memory for the Java Runtime Environment to continue.
Cannot create GC thread. Out of system resources.
java.lang.OutOfMemoryError: unable to create new native thread
此问题与ulimit -u有关,调大ulimit -u