Linux set user limit

If your application is giving error like below, or you want to increase user limit of open files, user limit of max processes follow this post.

System Requirement: max file descriptors [4096] likely too low, increase to at least [65536].
To see the current limit of the maximum number of processes for the oracle user, run:

ulimit –aH à to check Hard limits (-a display all limit)
ulimit -aS   Ã   to check Soft limit

ulimit –nH   Ã  Check hard limit of max open file (use -u for max user processes)
ulimit –nS   Ã  Check Soft limit of max open file

Example:
ulimit -Hn 4096

[aadmin@host1 opt]$ 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) 128540
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

The above value can be low for some application, you can change these value like below:

su - myuser
sudo vi /etc/security/limits.conf
<domain>        <type>  <item>  <value>

myuser                 -       nproc           65536
myuser                 -       nofile          63536

--- restart the server

Here:
nofile - max number of open files
nproc - max number of processes

Alternatively to make this change permanent, you could add "ulimit -u 65536" for nproc and "ulimit -n 63536" for nofile, to the ~oracle/.bash_profile file which is the user start up file for the bash shell on RHEL.

Verification:

aadmin@host1:~$ 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) 128595
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 10240
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 10240
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Note the user above is aadmin and changes is done for myuser user.

[root@host1 aadmin]# su - myuser -c 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) 128540
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 63536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 65536
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

NOTE: It is not recommend to set the "hard" limit for nofile for the oracle user equal to /proc/sys/fs/file-max. If you do that and the user uses up all the file handles, then the entire system will run out of file handles. That is why the hard limit should be set to 63536 and not 65536.

Post a Comment

Thanks for your comment !
I will review your this and will respond you as soon as possible.