The number of file handles that can be opened at the Linux system level file-max command

  
 

Simply, max-file represents the number of file handles that can be opened at the system level, and ulimit -n controls the number of file handles that can be opened at the process level.

man 5 proc, find file- Explanation of max: file-max specifies the number of file handles that can be opened by all processes in the system (system level, kernel-level). (The value in file-max s the maximum number of file handles that the Linux kernel Will allocate). When receiving an error message such as "Too many open files in system", you should have added this value.

# cat /proc/sys/fs/file-max185230# echo 100000 > /proc/sys/fs/file-max

or # echo ""fs.file-max=65535" >> /etc/sysctl.conf# sysctl -p

The kernel constant NR_OPEN imposes an upper limit on the value that may be placed in file-max. (This sentence means? Not too clear)

For the 2.2 kernel, you also need to consider inode- Max, the general inode-max is set to 4 times the file-max. For 2.4 and later kernels, there is no inode-max file.

file-nr can view the number of file handles currently open in the system. It contains 3 numbers: the first indicates the number of file descriptors that have been allocated, the second indicates the number of free file handles, and the third indicates Ability to open the maximum value of the file handle (consistent with file-max). The kernel will dynamically allocate file handles, but will not release them again (this may not fit the latest kernel, see the second in my file-nr The column is always 0, the first column has increments and subtractions.)

man bash, find the section that explains ulimit: provide available resources to the shell and the processes it starts (including file handles, number of processes, core Control of file size, etc. This is the process level, that is to say, how many file descriptors can be opened in a session and each process started in the system, how many child processes can be forked, etc. …

When the upper limit is reached, it will report an error "Too many open files" or encounter Socket/File: Can’t open so many files, etc.

Another thing to note is that each resource has a soft Hard limit, soft limit is inside The limit value imposed on the corresponding resource, the hard limit is the maximum value of the soft limit. The unauthorized call process can only specify its soft limit to a value in the range 0 to hard limit, and can irreversibly reduce its hard limit. The authorization process can arbitrarily change its hard and soft limits. The value of RLIM_INFINITY indicates no resource restrictions.

Use the -H and -S options respectively to specify settings that require hard/soft limits on the resource. Specify, hard limit and soft limit are set at the same time.

The limit value of the print resource. If you do not explicitly specify -H, the print is -S

To change the ulimit of apache, you can use /usr /sbin/apachectl Modify the value of ULIMIT_MAX_FILES in this script

The number of open file handles is too large. If the file descriptors are tcp sockets, etc, then you risk using up a large amount of Memory for the socket buffers and other kernel objects; this memory is not going to be swappable.

The other thing to remember is that socket connection is also a file.

Copyright © Windows knowledge All Rights Reserved