When doing Linux system operation, sometimes it will jump out too many open files prompt, that is, open too many files, it may be that you did not close normally when you close the program, the following small series will teach you to encounter too Many open files prompt how to solve.
answer a,
[root @ lxadmin nginx] # cat /proc /sys /fs /file-max
8192
File The maximum number of open files in the system
[root@lxadmin nginx]# ulimit -n
1024
Program limit can only open 1024 files
[root@lxadmin nginx]# ulimit -n 8192 Adjust
or permanently adjust the number of open files to be added at the end of the startup file /etc/rc.d/rc.local (at the end of /etc/sysctl.conf) Add fs.file-max=xxx is invalid)
ulimit -n 8192
Answer 2,
The Linux kernel sometimes reports "Too many open files", the cause is The file-max default (8096) is too small. To solve this problem, you can execute the following commands as root (or add them to the init script under /etc/rcS.d/*.)
# echo “65536” 》 /proc/sys/fs/File-max # for 2.2 and 2.4 kernels
# echo “131072” 》 /proc/sys/fs/inode-max #only for version 2.2 kernel
Answer 3
The method is to modify the operating system's open file limit, as follows:
1. Set the system according to the maximum number of open files, and check /proc/sys/fs/file- The max file confirms that the maximum number of open files has been set correctly.
# cat /proc/sys/fs/file-max
If the setting is too small, modify the /etc/sysctl.conf variable to the appropriate value. This will take effect after each reboot. If the setting is large enough, skip the next step.
# echo 2048 》 /proc/sys/fs/file-max
Edit the file /etc/sysctl.conf and insert it into the downstream.
fs.file-max = 8192
2. Set the maximum number of open files in the /etc/security/limits.conf file. Here is a line:
#
Add the following line.
* - nofile 8192
This line sets the default open file number for each user to 2048. Note that the "nofile" option has two possible restrictions. It is the 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 setting is used, the hard and soft settings will be 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.
Another situation is that when creating an index, there are two possibilities. One is that the merge factor is too small, resulting in the number of created files exceeding the operating system limit. In this case, the merge factor can be modified, and the operation can be modified. The number of open files in the system is limited; the other is that the consolidation factor is limited by the virtual machine memory and cannot be adjusted to a larger size. The number of docs that need to be indexed is very large. At this time, only the number of open files of the operating system can be modified. The limit is solved.
Based on this, I also modified one of the following configuration files
vi /etc/sysctl.conf
Add:
# Decrease the time Default value for tcp_fin_timeout connection
net.ipv4.tcp_fin_timeout = 30
# Decrease the time default value for tcp_keepalive_time connection
net.ipv4.tcp_keepalive_time = 1800
# Turn off tcp_window_scaling
net.ipv4.tcp_window_scaling = 0
# Turn off the tcp_sack
net.ipv4.tcp_sack = 0
# Turn off tcp_timestamps
net.ipv4.tcp_timestamps = 0
Then service network restart, these are optimizations related to TCP sockets.
Also need to be added in /etc/rc.d/rc.local has been made to take effect when the restart.
echo “30”"/proc/sys/net/ipv4/tcp_fin_timeout
echo “1800”"/proc/sys/net/ipv4/tcp_keepalive_time
Echo “0”"/proc/sys/net/ipv4/tcp_window_scaling
echo “0&0&quo;"/proc/sys/net/ipv4/tcp_sack
echo “0” /proc/sys/net/ipv4/tcp_timestamps
Because not all programs run under root, all Linux has a distinction between hard and soft open files. Ordinary users are limited by hard, no matter ulimit - The n value is adjusted to a high value, and the value of nofile in /etc/security/limits.conf cannot be reached.
After this optimization lsof -p $java_pid|
Wc -l can run more than 4,000 and will not throw too many open files.
The above is the introduction of the solution to the too many open files prompt. You can solve this problem by changing the system settings, closing the redundant programs, etc. Is it very simple? Try it out.
Fedora is a kind of Linux system, most of the operations also need commands to complete, there are u
When Ubuntu/Mint performs the PPA source addition operation, there is an error that
As a Linux administrator, you need to manage the system account reasonably, includi
If you create a lot of branches when using git under Linux, and then do not need to
How Linux uses commands in sysstat
Linux vim comment color can't see how to change?
How to set up Kde5 for Gentoo Linux system?
Linux system yum command function introduction
How Linux sets up port forwarding for intranet access to intranet
How to use commands to manage files in Linux
How to display the number of Linux subfolders and files
Linux uses awk to implement multi-line merge instances
How Linux prohibits specific ip address access
What is the difference between the Linux command rmdir and rm?
Method for monitoring Linux command completion using PV commands
How does Win10 use file inspection tools to repair damaged system files?
USBoot production U disk boot disk, USBoot user guide
How to use win10 paint 3d Microsoft paint 3d use graphic tutorial
Win10 how to install ps cc2015 win10 system installation Photoshop cc2015 detailed graphic tutorial
Haier computer U disk reloading system win7 step graphic tutorial
Steps to remove the small arrow of the windows7 desktop icon
Hearthstone legend T60 control riding legendary card group list
The new features of Win10 system
Win8 system application does not work properly how to solve
Win8 IE browser how to close the pop-up warning to close all tabs