惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - fengjian1585

关闭ingress 8443 端口 tomcat 设置 catalina.out 按天切割 Harbor 启用 Trivy 禁用 MinIO 的 Web Console 重定向功能 堆设置了8G,java进程却占用了12G内存 k8s优化选项 pod启动后一直containerCreating状态解决 Kubernetes Cilium网络组件和CoreDNS配置 mkfs对磁盘设置标签 K8S的CoreDns配置文件添加域名解析 nginx代理两套k8s ingress 不同域名 pip 搭建源 使用 kubectl debug 创建临时调试容器 openvpn server证书过期处理 - fengjian1585 Harbor Swagger接口泄露漏洞处理 Kafka 常见故障及解决方案 华为昇腾 910B GPU Nginx与Upstream之间产生大量TIME_WAIT连接的解决办法 debian libc.musl-x86_64.so.1 => not found
"too many open files" 文件句柄
fengjian1585 · 2025-04-18 · via 博客园 - fengjian1585

ulmit,展示了每个进程所能占用的文件句柄数量。

file-max,展示了操作系统能够占用的文件句柄数量总和,针对的是所有的进程。

cat /proc/sys/fs/file-max 
766722 

file-nr,展示了当前已经使用的句柄数量和总的句柄数量。可以拿来做监控。

cat /proc/sys/fs/file-nr 
1824  0 766722 

要支持百万连接,既要放开操作系统级别的句柄,也要放开进程级别的句柄。也就是说,ulimit和file-max的显示,都要大于百万才成。

设置进程的句柄个数

修改/etc/security/limits.conf

root soft nofile 1000000 
root hard nofile 1000000 
* soft nofile 1000000 
* hard nofile 1000000 

要看到这些改变是否已经对进程生效,可以查看进程的内存映射文件。比如cat /proc/180323/limits,其中会有详细的展示。

这个数值,也并不是想要设多大就多大的。它的大小上限,是由nr_open决定的。想要更大,就要修改/ect/sysct.conf 中fs.nr_open的值。

cat /proc/sys/fs/nr_open 
1048576 

那file-max又该如何修改呢?建议修改/etc/sysctl.conf文件,加入下面内容。足足有6百多万!

当文件数量超出的时候,就会报kernel: VFS: file-max limit 65535 reached的错误。