centos 7更改最大文件打开数

1、在之前修改文件最大连接数等直接修改 /etc/security/limits.conf文件即可,最近出现几次修改未生效问题。

2、经过排查发现可能跟ssh升级为8版本有关,尚未验证。

3、解决办法:

①修改 /etc/security/limits.conf文件,修改内容跟之前一样

vim /etc/security/limits .conf
* soft nofile 284888* hard nofile 204808
* soft nproc 284888
hard nproc 284888

vim /etc/security/limits.d/zg-noroc.conf
* soft nproc 284888
* hard nproc 204898

vim /etc/pam.d/login

#添加
session required  pam limits.so

②修改ssh配置文件/etc/ssh/sshd_config,将#UsePAM no 注释去掉并且改为yes,注意,如果直接改完重启ssh会出现登录输入正确密码也会被拒绝的情况,所以要首先执行步骤③之后再重启ssh

③修改/etc/pam.d/sshd文件,如果不存在直接新建即可

#%PAM-1.0
auth       required pam_sepermit.so
auth       include      password-auth
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    optional     pam_keyinit.so force revoke
session    include      password-auth

最后重启服务器查看

你可能感兴趣的:(centos,linux,运维)