Linux 系统级开启文件句柄 调优

系统级开启文件句柄 

max-file系统级别的能够打开的文件句柄的数量,Centos7默认是794168。


Max-file 与 ulimit -n 的区别

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

注:对于服务器来说,file-max和ulimit都需要设置,否则会出现文件描述符耗尽的问题。


查看系统级别最大文件句柄数

[root@node01 ~]# cat /proc/sys/fs/file-max
95874

修改最大文件句柄数:永久生效

1、修改配置文件加入内核参数/etc/sysctl.conf

复制代码
[root@node01 ~]# vi /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.file-max = 2000000
[root@node01 ~]# sysctl -p /etc/sysctl.conf 
fs.file-max = 2000000
[root@node01 ~]# cat /proc/sys/fs/file-max
2000000
复制代码

50W并发可设置 = 999999

注:修改范围为系统所有进程可打开的最大文件句柄

 

posted @   星火撩原  阅读(400)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示