正常情况下, /etc/security/limits.conf 的改动,重新登录就可以生效, 我遇到的问题最后的解决方案是重启虚拟机解决了,也参考了很多网上的文章,整理记录一下
为了优化linux性能,可能需要修改这个最大值。临时修改的话ulimit -n 204800就可以了,重启后失效。
ulimit -n
ulimit -u
* soft nofile 204800
* hard nofile 204800
* soft nproc 204800
* hard nproc 204800
我在解决这个问题时候,发现网上都是说修改这一个文件就行,但是我修改后重启服务器发现没更改过来。 后来发现,还需要修改两个文件。如果你重启后也没生效,请继续跟着往下修改。
在修改下面(2)、(3)所示的这些文件时候,有些文件可能并不存在,或者90-nproc.conf没有,但是有20-nproc.conf,建议从根路径下,自己亲自cd进去。然后一步步找到目标文件。如果90-nproc.conf不存在,修改类似的文件即可,即xx-nproc.conf
* soft nproc 204800
* hard nproc 204800
* soft nofile 204800
* hard nofile 204800
session required pam_limits.so
session required pam_limits.so
在 /etc/ssh/sshd_config 中, 存在:
UsePAM yes
不兼容方式:
* soft nofile 204800
* hard nofild 204800
兼容方式
root soft nofile 204800
root hard nofile 204800
es soft nofile 204800
es hard nofile 204800
参考:
https://evanwang.blog.csdn.net/article/details/103706237?utm_term=/etc/security/limits修改不生效&utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2allsobaiduweb~default-0-103706237&spm=3001.4430 https://blog.csdn.net/xinqiku/article/details/103312021