判断
判断
cat /proc/<PID>/limits | grep -i 'open files'
ls /proc/<PID>/fd | wc -l # 当前实际句柄数
cat /proc/sys/fs/file-nr # 系统级已分配与上限
ulimit -n # 当前会话上限调整
调整
ulimit -n 65535 # 会话级示例
# systemd 服务用 drop-in(limits.conf 对服务不生效):
systemctl edit app-web
# [Service]
# LimitNOFILE=65535
systemctl daemon-reload && systemctl restart app-web上调上限只是止血:句柄持续增长要按类型统计(lsof -p <PID>),排查 socket 与文件句柄泄漏。