欢迎大家关注我的 WX 公众号【小生末学】,相关技术文章会优先在公众号上发布~
原文地址在我的博客:https://blog.chenxiaosheng.com/posts/2022-06-14/linux-ulimit.html
ulimit 设置不当经常会引起各种各样的问题,比如很经典的 too many open files
,网上也有很多文章讲解 ulimit 设置,如 initscrip 设置、PAM、systemd 的配置等等。
由于 systemd 已经成为主流,本文以 Debian 11 bullseye 为环境理清正确的 ulimit 设置应该覆盖哪些配置。通常情况下这些配置在绝大多数 Linux 发行版会是通用的,并不局限于 Debian。
systemd
systemd 主要涉及 /etc/systemd/system.conf 和 /etc/systemd/user.conf 两个文件,需要配置的内容是以样的,以 ulimit 中 open files
和 max user processes
为例,我们需要配置如下两项: