The project was deployed to neokylin system, and after a period of time, the page exited to report this error.
First, the reason
Opening too many files is a common mistake in Linux system. There are too many files opened by the program. However, files here not only refer to files, but also include open communication links (such as socket) and listening ports. , so it can sometimes be called handle. This error can usually be called that the number of sentence handles exceeds the system limit.
The reason is that the files and communication links opened by the process at a certain time exceed the system limit. You can check the maximum number of sentence handles set by the current system through the command ulimit -a:
The line open files indicates the maximum number of handles that the system allows a single process to open at present, here is 1024.
Use the command lsof -p process id to view all the open files of a single process, use the command lsof -p process id | wc -l to calculate how many files the process has opened, and use lsof -p process id >: Openfiles.log to output the execution results to a log file for viewing.
Second, the solution
1. Increase the number of files allowed to open command mode.
ulimit -n 2048
This can set the maximum number of files opened by the current user to 2048, but this setting will be restored to the default value after restarting.
For non-root users, ulimit -n command can only be set to 4096.
If you want to make it bigger, you need sudo permission or root user.
2. Increase the number of files allowed to open-modify the system configuration file.
vim /etc/security/limits.conf
The leading * indicates all users, and users can be set as required, for example
Roy Software Archive 8 192
Roy's hard disk file 8 192
Note that the "nofile" item has two possible limitations. The item is hard and soft. In order for the modified maximum number of open files to take effect, these two limits must be set. If you use the "-"character setting, both the hard setting and the soft setting will be set.
3, check the program problem
If you know something about your program, you should estimate the upper limit of the number of files (links) opened by the program. If you think the number is abnormal, please use lsof -p process ID > in the first step. The Openfiles.log command gets all the details of the currently occupied handle for analysis.