系統引數nofile設定不生效問題

李行行丶發表於2022-03-09

1.直接登陸Oracle使用者如下報錯,從一下報錯資訊可以得知,open file修改沒有許可權,也就是nofile引數設定有問題

正在進行認證,請稍後 ......
Using username "oracle".
Last login: Wed Mar  9 09:25:23 2022 from xx.xx.xx.xx
stty erase ^H
-bash: ulimit: open files: cannot modify limit: Operation not permitted
[oracle@xxx~]$ ulimit -u -n
max user processes              (-u) 65536
open files                      (-n) 1024


2.從以上報錯馬上想到可能是/etc/profile中設定的引數要比/etc/security/limits.conf引數檔案中設定的要大導致的報錯

if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
grid  soft  nproc   65536 
grid  hard  nproc   65536
grid  soft  nofile  65536
grid  hard  nofile  65536
grid  soft  stcak   10240
grid  hard  stcak   10240
oracle  soft  nproc   65536
oracle  hard  nproc   65536
oracle  soft  nofile  65536
oracle  hard  nofile  65536
oracle  soft  stack   10240
oracle  hard  stack   10240
oracle  soft  memlock  -1
oracle  hard  memlock  -1
grid  soft  memlock  -1
grid  hard  memlock  -1


切換到oracle使用者檢視資源限制,這裡發現引數設定正常,那麼為什麼會出現此類問題呢?

這裡是因為UsePam引數未開啟,導致的問題

[root@xxx~]# su - oracle
[oracle@xxx~]$ ulimit -u -n
max user processes              (-u) 65536
open files                      (-n) 65536


3.問題解決

修改/etc/ssh/sshd_config配置檔案中,我們需要體新增如下配置.
UsePAM yes


重啟sshd服務

--此時發現瞭如下報錯,提示不支援UsePam,這裡是因為沒有安裝openssh,重新安裝即可

[root@xxx~]# service sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:/etc/ssh/sshd_config line 82: Unsupported option UsePAM
                                                           [  OK  ]

安裝openssh並重啟sshd服務

[root@xxx~]# rpm -qa | grep openssh  
[root@xxx~]# yum -y install openssh-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Determining fastest mirrors
base                                                                                                                                        | 2.9 kB     00:00     
epel                                                                                                                                        | 2.9 kB     00:00     
epel/primary_db                                                                                                                             | 6.0 MB     00:00     
extras                                                                                                                                      | 2.9 kB     00:00     
extras/primary_db                                                                                                                           |  27 kB     00:00     
updates                                                                                                                                     | 2.9 kB     00:00     
updates/primary_db                                                                                                                          | 967 kB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package openssh-server.x86_64 0:5.3p1-124.el6_10 will be installed
--> Processing Dependency: openssh = 5.3p1-124.el6_10 for package: openssh-server-5.3p1-124.el6_10.x86_64
--> Running transaction check
---> Package openssh.x86_64 0:5.3p1-124.el6_10 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================================================
 Package                                   Arch                              Version                                      Repository                          Size
===================================================================================================================================================================
Installing:
 openssh-server                            x86_64                            5.3p1-124.el6_10                             updates                            330 k
Installing for dependencies:
 openssh                                   x86_64                            5.3p1-124.el6_10                             updates                            278 k
Transaction Summary
===================================================================================================================================================================
Install       2 Package(s)
Total download size: 607 k
Installed size: 1.4 M
Downloading Packages:
(1/2): openssh-5.3p1-124.el6_10.x86_64.rpm                                                                                                  | 278 kB     00:00     
(2/2): openssh-server-5.3p1-124.el6_10.x86_64.rpm                                                                                           | 330 kB     00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                              2.5 MB/s | 607 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
python-meh-0.12.1-3.el6.noarch has missing requires of openssh-clients
  Installing : openssh-5.3p1-124.el6_10.x86_64                                                                                                                 1/2 
warning: /etc/ssh/moduli created as /etc/ssh/moduli.rpmnew
  Installing : openssh-server-5.3p1-124.el6_10.x86_64                                                                                                          2/2 
warning: /etc/ssh/sshd_config created as /etc/ssh/sshd_config.rpmnew
  Verifying  : openssh-5.3p1-124.el6_10.x86_64                                                                                                                 1/2 
  Verifying  : openssh-server-5.3p1-124.el6_10.x86_64                                                                                                          2/2 
Installed:
  openssh-server.x86_64 0:5.3p1-124.el6_10                                                                                                                         
Dependency Installed:
  openssh.x86_64 0:5.3p1-124.el6_10                                                                                                                                
Complete!
[root@hrdb2 ~]# service sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31462978/viewspace-2868490/,如需轉載,請註明出處,否則將追究法律責任。

相關文章