Linux的/proc/sys/fs/file-max决定了当前内核可以打开的最大的文件句柄数。

查看当前的值:

cat /proc/sys/fs/file-max

这个值在kernel的文档里是这样描述的:

The value  in  file-max  denotes  the  maximum number of file handles that the
Linux kernel will allocate. When you get a lot of error messages about running
out of file handles, you might want to raise this limit. The default value is
10% of RAM in kilobytes. To change it, just write the new number into the
file:

意思是file-max一般为内存大小(KB)的10%来计算,如果使用shell,可以这样计算:

grep -r MemTotal /proc/meminfo | awk '{printf("%d",$2/10)}'

一般我们不需要主动设置这个值,除非这个值确实较小(可能有各种其他原因导致file-max没有设置为内存的10%)

如何查看当前kernel的句柄:

cat /proc/sys/fs/file-nr

file-nr在内核文档里得解释如下:

Historically, the three values in file-nr denoted the number of allocated file
handles, the number of allocated but unused file handles, and the maximum
number of file handles. Linux 2.6 always reports 0 as the number of free file
handles -- this is not an error, it just means that the number of allocated
file handles exactly matches the number of used file handles.

/proc/sys/fs/file-max的更多相关文章

  1. 设置Linux打开文件句柄/proc/sys/fs/file-max和ulimit -n的区别

    max-file 表示系统级别的能够打开的文件句柄的数量.是对整个系统的限制,并不是针对用户的. ulimit -n 控制进程级别能够打开的文件句柄的数量.提供对shell及其启动的进程的可用文件句柄 ...

  2. stuff in /proc/sys/fs/

    This subdirectory contains specific file system, file handle, inode, dentry and quota information. 1 ...

  3. Linux打开文件句柄/proc/sys/fs/file-max和ulimit -n的区别

    max-file 表示系统级别的能够打开的文件句柄的数量.是对整个系统的限制,并不是针对用户的.ulimit -n 控制进程级别能够打开的文件句柄的数量.提供对shell及其启动的进程的可用文件句柄的 ...

  4. linux /proc/sys/fs/file-nr /proc/sys/fs/file-max /etc/security/limits.conf 三者的关联

    ulimit -n 对应 /etc/security/limits.conf 文件设置 问题: Can’t open so many files 对于linux运维的同学们,相信都遇到过这个问题. 在 ...

  5. Difference between ulimit, lsof, cat /proc/sys/fs/file-max

    https://unix.stackexchange.com/questions/476351/difference-between-ulimit-lsof-cat-proc-sys-fs-file- ...

  6. Linux TCP/IP调优参数 /proc/sys/net/目录

    所有的TCP/IP调优参数都位于/proc/sys/net/目录. 例如, 下面是最重要的一些调优参数,后面是它们的含义: /proc/sys/net/core/rmem_default " ...

  7. /proc/sys目录下各文件参数说明

    linux 其他知识目录 原文链接:https://blog.csdn.net/hshl1214/article/details/4596583 一.前言本文档针对OOP8生产环境,具体优化策略需要根 ...

  8. [转帖]/proc/sys目录下各文件参数说明

    /proc/sys目录下各文件参数说明 https://blog.csdn.net/luteresa/article/details/68061881   一.前言 本文档针对OOP8生产环境,具体优 ...

  9. Docker Run Cadvisor failed: inotify_add_watch /sys/fs/cgroup/cpuacct,cpu: no such file or directory

    原文链接:https://blog.csdn.net/poem_2010/article/details/84836816 没有找这个文件, 这是一个bug,在系统中,是cpu,cpuacct 可以去 ...

随机推荐

  1. MySQL中concat以及group_concat的使用

    摘自:https://www.jianshu.com/p/43cb4c5d33c1 说明: 本文中使用的例子均在下面的数据库表tt2下执行: 一.concat()函数 1.功能:将多个字符串连接成一个 ...

  2. php缓冲区

    我理解的要点: 1.所有缓冲区控制是在一个PHP执行进程中发生的.如:你打开n个demo.php,他们之间开启和关闭缓冲是互不影响的. 2.output_buffering在程序中用ini_set是不 ...

  3. 将Microsoft SQL Server 2000数据库转换成MySQL数据库

    1. 下载并安装MyODBC.(如果是XP请下载5.3的旧版本,8.x的新版本运行有问题) 2. 创建一个空的MySQL数据库. 3. 在Windows >> 控制面板 >> ...

  4. docker中 devicemapper驱动挂载容器镜像文件

    详解docker中容器devicemapper设备的挂载流程

  5. 图解http协议学习笔记

    一 ,基本概念 1互联网相关的各协议族为tcp/ip协议(网际协议),tcp/ip  ftp,DNS(通过域名解析ip地址),http(超文本传输协议) 还有很多协议 ,只是列举比较熟悉的 2tcp/ ...

  6. golang error (slice of unaddressable value)

    使用 Golang 将生成的 md5 转化为 string 的过程出现如下编译错误: 错误解析: 值得注意的一点是  func Sum(data []byte) [Size]byte  这个函数返回的 ...

  7. EFI系统分区如何删除

    U盘或者硬盘被做了系统安装盘. 结果在格式化都是失败,分区也不行. 有了新招 EFI分区是您的系统启动引导的分区,存放引导启动的文件的,因此它是一个操作系统独立的分区,实际上它是UEFI加载的固件和应 ...

  8. 使用Dockerfile制作镜像

    组成部分 基础镜像信息       FROM 维护者信息    MAINTAINER.LABEL 镜像操作指令       RUN.COPY.ADD.EXPOSE.WORKDIR.ONBUILD.US ...

  9. MySql 性能优化之 Explain

    MySQL 之 Explain 输出分析 背景 前面的文章写过 MySQL 的事务和锁,这篇文章我们来聊聊 MySQL 的 Explain,估计大家在工作或者面试中多多少少都会接触过这个.可能工作中实 ...

  10. 面试题:线程A打印1-10数字,打印到第5个数字时,通知线程B

    此题考查的是线程间的通信方式. 可以利用park/unpark实现 可以利用volatile关键字实现 可以利用synchronized结合wait notify实现 可以利用JUC中的CountDo ...