菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
94
0

K8s NodeHasFDPressure

原创
05/13 14:22
阅读数 34655

0x00 事件

收到 k8s 其中一台 node 发出的告警,信息如下:

Node condition FDPressure is now: True, reason: NodeHasFDPressure

[hostname:cn-hangzhou.172.16.2.17,kind:Node,lastday:1,message:Node condition FDPressure is now: True, 
reason: NodeHasFDPressure,name:cn-hangzhou.172.16.2.17,namespace:null,today:1]

在守护进程中 node-problem-detector-daemonset 的 workload 中,查找到关键日志:

I1106 14:50:31.518065       1 plugin.go:111] Add check result {Rule:0xc00003a380 ExitStatus:1 
Message:current fd usage is 850859 and max is 1048576} for rule &{Type:permanent Condition:FDPressure Reason:NodeHasFDPressure 
Path:/config/plugin/check_fd.sh Args:[] TimeoutString:<nil> Timeout:<nil>}

日志解释到:「当前的文件描述符已使用 850859,而最大是 1048576」。

而因为超出了 FD 最大的限制数的 80 %,所以才会收到该告警。

0x01 处理

先查了 /etc/security/limits.conf 文件,发现限制并不是日志中显示的 1048576,再看 /proc/sys/fs/file-max

[root@iZwt0Z jumpuser]# cat /proc/sys/fs/file-max
1048576

看来需要修改系统的总限制,也就是 /proc/sys/fs/file-max

[root@iZwt0Z jumpuser]# echo 6553560 > /proc/sys/fs/file-max
[root@iZwt0Z jumpuser]# cat /proc/sys/fs/file-max
6553560
[root@iZwt0Z jumpuser]# vim /etc/sysctl.conf
……
fs.file-max = 6553560

处理后,日志显示恢复正常:

I1106 14:58:31.206048       1 custom_plugin_monitor.go:138] New status generated: &{Source:fd-custom-plugin-monitor Events:
[{Severity:info Timestamp:2020-11-06 14:58:31.205994278 +0800 CST m=+508.031832028 Reason:NodeHasNoFDPressure 
Message:Node condition FDPressure is now: False, reason: NodeHasNoFDPressure}] 
Conditions:[{Type:FDPressure Status:False Transition:2020-11-06 14:58:31.205994278 +0800 CST m=+508.031832028 Reason:NodeHasNoFDPressure 
Message:node has no fd pressure}]}

参考:Linux可打开最大文件数

发表评论

0/200
94 点赞
0 评论
收藏