代码改变世界

解决linux提示 (too many file open)

2018-03-24 14:59  yang9527  阅读(526)  评论(0)    收藏  举报

开文件limits.conf,修改文件(注意如果操作的用户为root,必须指定写出root.)。

 

# - NOTE: group and wildcard limits are not applied to root.
# To apply a limit to the root user, <domain> must be
# the literal username root.

vi /etc/security/limits.conf

* soft nofile 30720
* hard nofile 30720
root soft nofile 30720
root hard nofile 30720

查看当前文件数量状态使用命令ulimit -a

 

如果某项服务已经启动,再动态调整ulimit是无效的,特别是涉及到线上业务就更麻烦了。
这时,可以考虑通过修改/proc/’程序pid’/limits来实现动态修改!!

程序PID可以使用 ps -aux 查找对应的PID号 。