产品动态
公共镜像更新动态
操作系统官方停止维护计划
产品公告


/etc/pam.d/login 这个 pam 模块进行校验,在 /etc/pam.d/login 配置中默认会引入 system-auth 模块进行认证,system-auth 模块默认会引入 pam_limits.so 模块进行认证。system-auth 的默认配置如下图所示:

pam_limits.so 模块的主要功能是限制用户会话过程中对各种系统资源的使用情况。默认情况下该模块的配置文件是 /etc/security/limits.conf,该配置文件规定了用户可使用的最大文件数、最大线程数、最大内存等资源使用量。参数说明如下表:参数 | 说明 |
soft nofile | 可打开的文件描述符的最大数(软限制)。 |
hard nofile | 可打开的文件描述符的最大数(硬限制),不能超过该设定值。 |
fs.file-max | 系统级别的能够打开的文件句柄(内核中 struct file)的数量。针对整个系统的限制,并不针对用户。 |
fs.nr_open | 单个进程可分配的最大文件描述符数目(fd 个数)。 |
/etc/security/limits.conf 中关于 root 用户最大能打开的文件描述符个数配置错误,正确的配置应满足 soft nofile ≤ hard nofile ≤ fs.nr_open 关系。soft nofile、hard nofile 及 fs.nr_open 值是否满足 soft nofile ≤ hard nofile ≤ fs.nr_open 关系:soft nofile 及 hard nofile 值。cat /etc/security/limits.conf

fs.nr_open 值。sysctl -a 2>/dev/null | grep -Ei "file-max|nr_open"

/etc/security/limits.conf 文件,在文件末尾添加或修改如下配置:root soft nofile:100001root hard nofile:100002/etc/sysctl.conf 文件,在文件末尾添加或修改如下配置:soft nofile ≤ hard nofile ≤ fs.nr_open 关系时,此步骤非必选,可在系统最大限制不足时再进行调整。fs.file-max = 2000000fs.nr_open = 2000000sysctl -p
文档反馈