I saw this the other day on my file server. It’s a Centos 6 system. When I executed the testparm command to see what’s configured I got that weird error message. According to the Internet should this not be an issue, but I don’t like error messages or warnings. To fix this problem one need to know what it means. The ulimit is a mechanism to restrict the amount of various resources that a user or process can consume. To check your current limits, just type in
[Juser@centos6 ~]$ ulimit -a and you’ll see an output like the one below.
core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 16006 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) 10240 cpu time (seconds, -t) unlimited max user processes (-u) 1024 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
These are default values that are good for most purposes. Sometimes you’ll find that you run into problems with these default values. Let’s say that you run a database on your server and every connection to it and every statement creates a new process. We also assume that the database runs under a particular userID. Depending on the number of parallel requests to that database, the number of ‘maximum user processes’ might be a bit too small. So whenever your users are moaning about delays or higher latency especially while peek times, it’s worse to have a look at these values and compare them with the current state. Changing the values can also create some problems, so you should be confident in what you are doing.
Here I decreased the file size to 1 block (1kB) and run into a problem with creating a new file.
[letmein@centos5 ~]$ ulimit -f 1 [letmein@centos5 ~]$ ls -alis > ls.txt File size limit exceeded (core dumped) [letmein@centos5 ~]$ cat ls.txt total 168 738 4 drwxrwxrwt. 35 root root 4096 Sep 20 10:25 . 2 4 dr-xr-xr-x. 35 root root 4096 Aug 16 03:13 .. 10216 8 -r-------- 1 root root 4368 Feb 25 2011 X 89156 8 -r-------- 1 root root 4368 Jan 18 2011 XX 132798 4 drwx------ 2 root root 4096 Sep 20 01:01 xxxxxxx 131350 4 drwxr-xr-x 3 root root 4096 Mar 7 2012 xxxxxxxxxxx 131138 4 drwx------. 2 root root 4096 Jul 24 08:39 .xxx-0 139440 4 drwxr-xr-x 3 root root 4096 Aug 23 2012 xxxxxx 132794 4 drwx------ 2 root rot 4096 Jul 2 2012 gpg-3gJ7Vb 131091 4 drwx------ 2 root root 4096 Oct 27 2011 gpg-C7UblN 139404 4 drwx------ 2 root root 4096 Mar 7 2012 gpg-EMuoRu 139251 4 drwx------ 2 root root 4096 Aug 6 2012 gpg-euhn04 131640 4 drwx------ 2 root root 4096 Apr 22 2012 gpg-Hu5RI8 132772 4 drwx------ 2 root [letmein@centos5 ~]$
With version 6 of RHEL and Centos, there are some additional limits set. There are two types of limits, hard and soft. Where only the soft one can be changed by a user. The hard limit can only be set by the superuser and enforced by the Kernel.
There are two ways to set/change these limits.
- As a normal user you can set a value directly by using the command line.
[juergen@centos6 ~]$ ulimit -u 2048This increases the number of maximal user processes to 2048.This change is valid in the shell the command has been executed. To make this change non-volatile, just add the above command to your .bashrc file.
- Only the superuser has permission to set the defaults. These defaults are stored in the file /etc/security/limits.conf. As mentioned before, is it possible to create limits.conf per application/user since version 6. These files are stored under /etc/security/limits.d/ and will be included automatically. To get these values re-read you have to reboot your host.
After reading this article you should be able to fix the rlimit_max problem by setting the open files value to 16384. For more information have a look at the man pages for ulimit and limits.conf.