1. 程式人生 > >【Linux】Linux修改openfiles後不生效問題?

【Linux】Linux修改openfiles後不生效問題?

usr 上下 sshd 文件 tro con com 物理機 str

#次故障問題環境背景:

Centos7.4物理機,升級過ssh和ntp:

技術分享圖片

技術分享圖片

#一般只需要在此文件後面添加4行就行,配置後即可生效(exit再次登錄即可生效),此次配置後沒生效,reboot還是沒生效在root下ulimit -a 2個參數都沒生效,但是在普通用戶下顯示生效,但實際應該是不生效的

cat /etc/security/limits.conf |tail -8

技術分享圖片

* soft nproc 65535

* hard nproc 65535

* soft nofile 102400

* hard nofile 102400

可通過ulimit -a來查看2個數值;

#發現次服務器上沒有/usr/lib/systemd/system/sshd.service這個文件,於是從虛機上下載這個文件並上傳,發現openfiles還是不能生效:

技術分享圖片

#此時修改/etc/ssh/sshd_config文件中UsePAM yes後,發現openfiles=生效(也就是在root下ulimit -a也可以顯示正確),但是此時ssh不到該服務器,提示密碼錯誤而ssh自己完全ok

技術分享圖片

#經過排查是升級ssh時可能少加一些參數了:或者使用yum remove -y openssh刪除了相關的文件了,導致丟失文件,從而配置了openfile不生效,發現cat /etc/pam.d/sshd次文件不存在,於是從虛機上下載這個文件並上傳:

[root@foryou_zxl ~]# vim /etc/pam.d/sshd

技術分享圖片

最終重新ssh發現,UsePAM yes,同時openfiles生效了:完美;

技術分享圖片

技術分享圖片

【Linux】Linux修改openfiles後不生效問題?