系统
# cat /etc/redhat-release
CentOS release 6.8 (Final)
# uname -r
2.6.32-642.el6.x86_64
一般最大打开文件数会是系统内存的10%(以KB来计算)(称之为系统级限制),查看系统级别的最大打开文件数可以使用sysctl -a | grep fs.file-max命令查看,如16G RAM系统的系统级限制为
# free -m
total used free shared buffers cached
Mem: 15834 15685 149 0 133 14414
-/+ buffers/cache: 1136 14698
Swap: 32767 24 32743
# sysctl -a | grep fs.file-max
fs.file-max = 1608241
修改
# ulimit -SHn 1608240 //临时修改
# ulimit -n
1608240
# echo "* - nofile 1608240" >> /etc/security/limits.conf //永久修改,重启生效
# tail -n1 /etc/security/limits.conf
* - nofile 1608240