美文网首页
Centos 7 修改 ulimit 后 systemctl 启

Centos 7 修改 ulimit 后 systemctl 启

作者: 不做秃顶的程序猿 | 来源:发表于2020-10-12 23:10 被阅读0次

背景

线上服务报错 too many open files 。修改 ulimit 配置后,使用 systemctl 重启服务,仍然报 too many open files
通过 /proc/进程ID/limits 查看,发现进程的 Max open files 没有变化

解决方案

vim /etc/systemd/system.conf
修改如下两个配置

DefaultLimitNOFILE=102400
DefaultLimitNPROC=65535

重启服务器后即生效

原因

在Centos 7系统中,/etc/security/limits.conf 文件的配置作用域缩小了。/etc/security/limits.conf 的配置,只适用于通过PAM认证登录用户的资源限制,它对systemd的service的资源限制不生效。
对于systemd service的资源设置,则需修改全局配置,全局配置文件放在/etc/systemd/system.conf/etc/systemd/user.conf

相关文章

网友评论

      本文标题:Centos 7 修改 ulimit 后 systemctl 启

      本文链接:https://www.haomeiwen.com/subject/opvppktx.html