Tuesday, 6 September 2016

About limits.conf

You probably know about ‘nproc’ limits in Linux which are set in /etc/limits.conf
Nproc is defined at OS level to limit the number of processes per user.
Example :
user soft nproc 8192
user hard nproc 8192

Issue
Normal user is unable to login on the system with an error "fork: Resource temporarily unavailable" 
 
# su – <user> 
-bash: fork: retry: Resource temporarily unavailable 
-bash: fork: retry: Resource temporarily unavailable 
-bash: fork: retry: Resource temporarily unavailable 
-bash: fork: retry: Resource temporarily unavailable 
-bash: fork: Resource temporarily unavailable

Resolution
Increase the value of "nproc" parameter for user or all user's in /etc/security/limits.conf
 
#ps h -Led -o user | sort | uniq -c | sort -n
      1 nrpe
      1 ntp
      1 rpc
      1 rpcuser
      2 dbus
      2 postfix
      3 haldaemon
    401 wildfly
    440 root
    934 user






Set it high but monitor it when the number of processes reaches maximum of limit.
 

#ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 125379
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 8192
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 8192
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
 


#vim /etc/security/limits.conf 
user           soft    nproc           8192
user           hard    nproc           8192
user           soft    nofile          8192
user           hard    nofile          8192





These limits will be applied after reboot.
If you want to apply changes without reboot, modify /etc/pam.d/config-util by adding this line at the end of file: 

session required pam_limits.so

0 comments:

Post a Comment