首页 > 系统服务 > 详细

Ubuntu /etc/security/limits.conf 不生效问题

时间:2019-06-12 12:45:54      阅读:912      评论:0      收藏:0      [点我收藏+]

一、问题描述

修改 /etc/security/limits.conf ,重启之后不生效

内容如下:

* soft nofile 2048576
* hard nofile 2048576
root soft nofile 2048576
root hard nofile 2048576
* soft nproc 80480
* hard nproc 80960
root soft nproc 80480
root hard nproc 80960

 

二、解决问题

根据网上资料的说法有几种

1. 修改 /etc/ssh/sshd_config

开启这2项

UsePAM yes
UseLogin yes

 

2. 以下几个文件

/etc/pam.d/login
/etc/pam.d/su
/etc/pam.d/sshd

确保开启了pam_limits.so

session    required   pam_limits.so

 

3. 重启系统

注意:修改了/etc/security/limits.conf ,必须要重启,才能生效。

 

以上几个,都测试了一下,open files没有生效!max user processes倒是生效了

root@ubuntu:~# ulimit -a
core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 7832 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 80480 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited

 

最后终于找到原因了,是因为 soft nofile 设置的值过大,导致还原为默认值 1024

重新修改 /etc/security/limits.conf

* soft nofile 1000000
* hard nofile 1000000
root soft nofile 1000000
root hard nofile 1000000
* soft nproc 80480
* hard nproc 80960
root soft nproc 80480
root hard nproc 80960

 

再次重启,效果如下:

root@ubuntu:~# ulimit -a
core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 31392 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1000000 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 80480 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited

 

本文参考链接:

https://blog.51cto.com/jonyisme/1919075

 

Ubuntu /etc/security/limits.conf 不生效问题

原文:https://www.cnblogs.com/xiao987334176/p/11008812.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!