美文网首页
解决Linux打开文件数过多error:too many ope

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

作者: beyond阿亮 | 来源:发表于2021-11-05 21:48 被阅读0次

    解决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 -Hn 和 ulimit -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

    相关文章

      网友评论

          本文标题:解决Linux打开文件数过多error:too many ope

          本文链接:https://www.haomeiwen.com/subject/sccdzltx.html