解决Linux打开文件数过多error:too many open files

解决Linux打开文件数过多error:too many open files

#查看当前的最大打开文件数
ulimit -n
#默认只有1024,当负载较大的服务器时,很容易遇到error: too many open files。因此,需要将其改大。

#可临时修改,但重启后就无效
ulimit -n 65535 

#查看当前系统的所有限制值
ulimit -a 

#修改配置文件,永久生效
vim /etc/security/limits.conf
#在最后加入  
#指定root用户的限制
root soft nofile 5000  
root hard nofile 8000 

#或者

# *表示所有用户, 但有的系统不认, 需要具体的用户名
#* soft nofile 4096  
#* hard nofile 4096  

soft nofile表示软限制,hard nofile表示硬限制,软限制要小于等于硬限制。

使用 ulimit -Hnulimit -Sn 命令可以分别查看当前进程用户的 hard 和 soft 的限制数

参考链接:
http://blog.csdn.net/fdipzone/article/details/34588803
http://www.cnblogs.com/tankaixiong/p/4064708.html
https://blog.csdn.net/nchu2020/article/details/100608624
https://www.iteye.com/blog/jameswxx-2096461
https://www.xp.cn/jishu-php-3045.html

猜你喜欢

转载自blog.csdn.net/yinjl123/article/details/131815590