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. 探究重构代码(Code refactoring)

    Code refactoring 是什么 在不改变软件的外部行为的条件下,通过修改代码改变软件内部结构,将效率低下和过于复杂的代码转换为更高效.更简单和更简单的代码. 怎样执行Code refacto ...

  2. linux xz压缩解压

    1. 解压 xz 格式文件 方法一: 需要用到两步命令,首先利用 xz-utils 的 xz 命令将 linux-3.12.tar.xz 解压为 linux-3.12.tar,其次用 tar 命令将 ...

  3. jquery版本轮播图(es5版本,兼容高)

    优势:基于es5,兼容高.切换动画css配置,轻量,不包含多余代码,可扩展性很高,多个轮播图不会冲突,可配置独有namespace 注: 1.项目需要所写,所以只写了页码的切换,未写上一页下一页按钮, ...

  4. 对vi/vim的一些看法

    早在网上看到别人如何把vi吹得神乎其神了,决定试着用一下.不过还是发现太麻烦了,因为我是在windows系统下面的,网络的原因无法使用linux系统(无校园电信客户端). 首先vim只是一个文本编辑器 ...

  5. 服务器控件调用JS函数

    是服务器端控件,不能在JS里直接调用,但可以在aspx.cs 里写方法可以调用JS函数,比如JS方法名称是check(), function check() {   alert(document.ge ...

  6. WPF 绑定数据方式

    ======================================================================== Foreground="{Binding P ...

  7. 【工具使用】kali 安装后要做的事情

    日期:2019-07-17 10:43:40 介绍:修改分辨率.修改时区.修改源 0x01. 修改分辨率 kali 在安装完成之后,分辨率过低,需要修改分辨率.  然后依次选择 [settings] ...

  8. IDEA反编译jar包源码

    1.maven 项目查看jar源码 如何在idea中查看jar包源码   文章目录 准备jar包 idea打开文件夹 最后一步 准备jar包 例如,我准备看resin的jar,在桌面准备了一份 ide ...

  9. 精读《Monorepo 的优势》

    1. 引言 本周精读的文章是 The many Benefits of Using a Monorepo. 现在介绍 Monorepo 的文章很多,可以分为如下几类:直接介绍 Lerna API 的: ...

  10. 自己写一个Layout

    1 Layout是ViewGroup的子类 LinearLayout.FrameLayout都是ViewGroup的子类,自己写的Layout也是ViewGroup的子类. 2 步骤 第一,自己的La ...