Centos7修改了最大文件打开数不生效

在limit.conf配置文件中添加了如下配置

* soft nproc 65535
* hard nproc 65535
* soft nofile 131070
* hard nofile 131070

另启终端查看最大文件打开数ulimit -n仍然为1024

经过各种百度搜查,发现以前更新过openssl和openssh,导致/etc/pam.d/sshd模块丢失,当sshd_config设置UsePAM yes的时候,无法ssh,我们现在添加sshd配置

[root@k8s-master idcs]# cat /etc/pam.d/sshd
#%PAM-1.0
auth       required    pam_sepermit.so
auth       substack     password-auth
auth       include      postlogin
# Used with polkit to reauthorize users in remote sessions
-auth      optional     pam_reauthorize.so prepare
account    required     pam_nologin.so
account    include      password-auth
password   include      password-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open env_params
session    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    include      password-auth
session    include      postlogin
# Used with polkit to reauthorize users in remote sessions
-session   optional     pam_reauthorize.so prepare

然后重启sshd并另启终端查看最大文件打开数(生效了)

[root@k8s-master idcs]# systemctl restart sshd
[root@k8s-master idcs]# ulimit -n
131070
原文地址:https://www.cnblogs.com/cpw6/p/13186736.html