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

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - 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的错误。