linux
  • Introduction
  • Yum
    • 基础yum源的配置
    • 为yum源配置代理
    • Centos指定版本的yum源
    • 环境变量
    • 本地yum源
    • 制作yum源
      • 同步yum源
    • epel源
  • Iptables
    • 基本匹配条件
    • Match-Extensions
      • Addrtype
      • Set
      • TCP
    • Target-Extensions
      • DNAT
      • LOG
    • Iptables规则持久化
    • 连接追踪
  • LVS
    • Ipvsadm命令
  • 磁盘与分区
    • 创建分区
    • 格式化与挂载
    • fstab
    • LVM
      • LVM扩容
    • swap分区
    • tmpfs
  • 网络相关
    • 重命名网卡
    • resolv.conf
    • Tcpdump
    • dig与nslookup
  • Other
    • CPU与内存
    • 进程
      • 僵尸进程
    • SSH密钥登录
    • 用户管理
    • Crontab
  • Nofile
    • 原理
  • 常用软件安装篇
    • MYSQL
    • 系统与内核
      • 指定内核启动
    • NFS
    • Haproxy
    • Keepalived
    • Squid
    • Redsocks
    • Shadowsocks
    • 时钟同步
  • 内存
Powered by GitBook
On this page

Was this helpful?

Nofile

1、/etc/systemd/system.conf

该文件会影响以systemd管理的进程(即xxx.service),比如docker服务如果是用systemd管理,那么dockerd进程的打开文件数会受到该文件的影响。 同时我们也可以在xxx.service中修改,以覆盖/etc/systemd/system.conf的值

2、/etc/systemd/system.d/

该目录下的文件的值会覆盖/etc/systemd/system.conf中的值

3、/etc/security/limits.conf

该文件会影响某个用户下的进程,可以简单理解为该用户下的单个进程的打开文件数上限

3、/etc/security/limits.d/

该目录下的文件中的配置会覆盖/etc/security/limits.conf的值

4、容器

容器中的进程是以root用户运行的,但是容器中的进程的打开文件数上限,是由docker的启动参数控制的,该参数的默认值为65536, 所以容器中的进程的打开文件数与上述的配置没有关系。

比如,我们可以通过以下的方式来修改容器中进程的Soft NoFile与Hard NoFile都为1048576

$ dockerd --default-ulimit nofile=1048576:1048576

5、上面可配置的地方这么多,如何查看某个进程真正的打开文件数上限?

$ cat /proc/<pid>/limits

6、如果查看一个进程当前打开了多少个文件?

$ ls -l /proc/<pid>/fd | wc -l
PreviousCrontabNext原理

Last updated 5 years ago

Was this helpful?