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. tomcat+nginx负载均衡

    一.       工具 nginx-1.8.0 apache-tomcat-6.0.33 二.    目标 实现高性能负载均衡的Tomcat集群: 三.    步骤 1.首先下载Nginx,要下载稳定 ...

  2. sock( ) bind( ) connect( )

    Linux下的socket()函数 调用头文件<sys/socket.h>中的socket函数 int socket(int af, int type, int protocol); 1) ...

  3. 使用collection查询集合属性

    介绍resultMap中使用collection查询集合属性 业务需求,查询部门中的多个人员 public class Department { private Integer id; private ...

  4. Git 版本管理工具命令速查

    转自:http://www.jb51.net/article/55442.htm 一. Git 常用命令速查 git branch 查看本地所有分支git status 查看当前状态 git comm ...

  5. Jmeter接口测试系列之判断测试结果

    在使用jmeter进行接口测试时,我们需要根据测试用例判断其测试结果是否一致,判断其执行是否成功. 在jmeter中也可以使用响应断言去判断,但是有时我们需要根据不同的用例,其判断条件不同,所以这里我 ...

  6. C# 无焦点获取扫码枪扫码信息

    代码网上有的是,多是需要窗体焦点直接show出扫码信息(usb,模拟键盘,hook) 怎样才能真的无焦点获取? 用串口方式 usb转串口 以接收串口通讯消息的方式获取扫码信息

  7. ES6标准入门 第五章:正则的扩展

    1.RegExp 构造函数 ES5的缺陷: ES5中构造函数的参数有两种情况: (1)参数是字符串,这时第二个参数表示正则表达式的的修饰符(flag). var reg = new RegExp( & ...

  8. cocos2dx基础篇(11) 点九图CCScale9Sprite

    [3.x] (1)去掉"CC" [v3.3] 我们在 ui模块 下实现了一个新的Scale9Sprite类.它的内部实现比之前的Scale9Sprite更为简洁,功能也更为强大. ...

  9. 【Qt开发】事件循环与线程 二

    事件循环与线程 二 Qt 线程类 Qt对线程的支持已经有很多年了(发布于2000年九月22日的Qt2.2引入了QThread类),Qt 4.0版本的release则对其所有所支持平台默认地是对多线程支 ...

  10. sql limit order by and where

    1 sql limit limit size,返回前size行. limit offset , size,返回offset开始的size行,offset从0行开始. 2 sql limit with ...