在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