1、修改配置
# 系统
cat <<'CAT_END' > /etc/sysctl.conf
fs.file-max = 65535
CAT_END
sysctl -p
# 用户
cat <<'CAT_END' > /etc/security/limits.conf
# 添加
* hard nofile 65535
* soft nofile 65535
root hard nofile 65535
root soft nofile 65535
CAT_END
# Systemd
cat <<'CAT_END' > /etc/systemd/system.conf
DefaultLimitCORE=infinity
DefaultLimitNOFILE=65535
DefaultLimitNPROC=65535
systemctl daemon-reexec
CAT_END
2、验证设置
# 查看系统限制
cat /proc/sys/fs/file-max
# 查看用户硬限制
ulimit -Hn
# 查看用户软限制
ulimit -Sn
# 查看某进程的限制
# 将 PID 替换为具体的进程 ID
cat /proc/PID/limits