Failed to Collect Data Because the Number of File Descriptors Exceeded the Maximum
Symptom
A data collection task failed because the number of file descriptors exceeded the maximum. Increase the maximum number of file descriptors as required.
Possible Cause
The process of the data collection task requires more file descriptors than it is allowed to have.
Troubleshooting Procedure
Exercise caution when changing the maximum number of file descriptors because it may bring the following risks:
- Excessive system resource consumption: If the maximum number of file descriptors is set to a large value, more system resources will be consumed, which may slow down or crash the system.
- Security issue: If the maximum number of file descriptors is set to a large value, the system is prone to attacks because attackers can use more file descriptors to consume system resources or perform malicious operations.
- Application compatibility issue: If the maximum number of file descriptors is set to a large value, some applications may crash or cannot work properly.
root user:
- Locate the service file of gunicorn_framework.service.
1systemctl status gunicorn_framework.service
Figure 1 Service details
- Add a configuration item.
1vi /usr/lib/systemd/system/gunicorn_framework.serviceAdd the LimitNOFILE parameter to the [Service] section.
Figure 2 New configuration item
Press Esc, type :wq!, and press Enter to save the file and exit.
- Restart gunicorn_framework.service.
1 2
systemctl daemon-reload systemctl restart gunicorn_framework.service
Common user:
- Display the soft and hard limits of the file descriptor of the current user.
- Soft limit
ulimit -n # Output the soft limit.
- Hard limit
ulimit -Hn # Output the hard limit.
- Soft limit
- If the number of file descriptors for the soft limit is different from that for the hard limit, set the soft limit to the hard limit.
- Open the shell configuration file.
vim ~/.bashrc
- Add the following content to the file, setting the soft limit to the hard limit:
ulimit -Sn $(ulimit -Hn)
Press Esc, type :wq!, and press Enter to save the file and exit.
- Load the configuration file.
source ~/.bashrc
- Open the shell configuration file.
- (Optional) If the problem persists after the soft limit is increased to the hard limit, contact the root user to modify the system file.
- Open the configuration file.
vim /etc/security/limits.conf
- Add the following content to the file:
test001 hard nofile 1048576
Replace the example common user test001 with the actual user name. Press Esc, type :wq!, and press Enter to save the file and exit.
- After the configuration is complete, the common user needs to log in again for the configuration to take effect.
- Open the configuration file.
Parent topic: FAQs