zoukankan      html  css  js  c++  java
  • linux配置用户最大打开文件数(错误Too many open files)

    环境:centos7

    1、通过命令ulimit -a查看当前进程可以打开的最大文件数

    [root@tool-19 conf]# ulimit -a
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 127947
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 1024                       #最大文件打开数
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 127947
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited

    2、还可以通过命令ulimit -n 直接查看当前进程可以打开文件的最大数量

    [root@tool-19 conf]# ulimit -n
    1024

    3、上面两个命令是查看当前进程最大文件数,而系统也有最大文件数,它指的是所有进程可以打开的文件数量,如下图所示的命令可以查看当前系统的最大文件数

    [root@tool-19 conf]# cat /proc/sys/fs/file-max 
    3247213
    配置最大文件打开数
    [root@tool-19 conf]# vim /etc/sysctl.conf  #文件末尾加入配置内容:
    fs.file-max = 4000000
    [root@tool-19 conf]# sysctl -p  #然后执行命令,使修改配置立即生效:

    4、通过命令ulimit -a 65535可以进行更改,只对当前会话生效

    [root@tool-19 conf]# ulimit -n 65535
    [root@tool-19 conf]# ulimit -n
    65535

    5、要永久生效,可以通过输入下图所示的两条命令来达到更改最大文件数永久生效的目的

    [root@tool-19 conf]# echo '* soft nofile 65535' >> /etc/security/limits.conf 
    [root@tool-19 conf]# echo '* hard nofile 65535' >> /etc/security/limits.conf
    #退出重新进入,查看生效
    [root@tool-19 ~]# ulimit -n
    65535
    做一个决定,并不难,难的是付诸行动,并且坚持到底。
  • 相关阅读:
    FLASH置于底层
    图片等比缩放
    fedora 系统使用 Broadcom BCM4312 无线网卡(转)
    ubuntu语言问题
    轻松安装、卸载Linux软件
    redhat6.0下使用vnc
    http网络安装centos 5.5系统总结
    如何在windows下搭建python的IDE开发环境
    对做技术的一点思考
    C++继承类和基类之间成员函数和虚函数调用机制
  • 原文地址:https://www.cnblogs.com/wukc/p/13292403.html
Copyright © 2011-2022 走看看