Linux too many open files solution

  

This problem occurs because of the limitation of system on the number of files opened by the program. Use the ulimit -a command to view [root@5 ~]# 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) 4096 max locked memory (kbytes, -l) 32 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) 4096 virtual memory (kbytes, -v) Unlimited file locks (-x) unlimited As you can see, the limit on open files is 1024. We can increase the number of files that can be opened by modifying this value. ************************************************** **************** Temporary modification: Change it to 2048, use ulimit -n 2048. When you increase the value of open files to a certain extent, your Too many open files It will not appear again. ************************************************** **************** To change these two parameter values ​​for a long time, modify /ect/security/limits.conf and add two lines to the file:

The code is as follows: * - nofile 65535 * - nproc 65535

Note: This line sets the default open file number for each user to 2048. Note that the "nofile" item has two possible restrictions. It is hard and soft under the item. In order for the modified maximum open file count to take effect, these two restrictions must be set. If the "-" character is set to <type>, the hard and soft settings are set at the same time. The hard limit indicates the maximum value that can be set in the soft limit. The soft limit refers to the setting value that the current system is in effect. The hard limit value can be lowered by ordinary users. But can't increase. The soft limit cannot be set higher than the hard limit. Only the root user can increase the hard limit value. When adding a file limit description, you can simply double the current value. The example is as follows, if you want to increase the default value of 1024, it is best to increase to 2048, if you want to continue to increase, you need to set to 4096. Finally, use ulimit -a to check again, the value of open files, if there is no problem, it has been changed. ************************************************** **************** ---------------------------------- --------------------------- After the above settings, log out of the shell and log in again, still does not take effect, to point to the //etc /profile Next, add a line ulimit -SHn 51200 (note that there is already a setting about ulimit) to rc.local, add a line ulimit -SHn 51200 (I don't know if this is necessary, in fact, I have not added) ulimit -S -c 0 > /dev/null 2>&1 This statement sets the settings for software resources and core file size

Copyright © Windows knowledge All Rights Reserved