linux 打开文件数too many open files解决方法

出现这句提示的原因是程序打开的文件/socket连接数量超过系统设定值。
查看每个用户最大允许打开的文件数量
ulimit -a
其中 open files (-n) 1024 表示每个用户最大允许打开的文件数量是1024


当前系统文件句柄的最大数目,只用于查看,不能设置修改
cat /proc/sys/fs/file-max

查看某个进程的打开文件限制数
cat /proc/10446(pid)/limits

设置open files 数值方法
ulimit -n 4096 种设置方法在重启后会还原为默认值。

永久设置方法:
vim /etc/security/limits.conf
在最后加入
* soft nofile 4096
* hard nofile 4096
生效需要重启系统

 

posted @ 2017-04-07 13:06  一心行走  阅读(1217)  评论(0编辑  收藏  举报