我要评分
获取效率
正确性
完整性
易理解

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:

  1. 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.
  2. 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.
  3. 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:

  1. Locate the service file of gunicorn_framework.service.
    1
    systemctl status gunicorn_framework.service
    
    Figure 1 Service details
  2. Add a configuration item.
    1
    vi /usr/lib/systemd/system/gunicorn_framework.service
    

    Add 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.

  3. Restart gunicorn_framework.service.
    1
    2
    systemctl daemon-reload
    systemctl restart gunicorn_framework.service
    

Common user:

  1. 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.
  2. 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.
    1. Open the shell configuration file.
      vim ~/.bashrc
    2. 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.

    3. Load the configuration file.
      source ~/.bashrc
  3. (Optional) If the problem persists after the soft limit is increased to the hard limit, contact the root user to modify the system file.
    1. Open the configuration file.
      vim /etc/security/limits.conf
    2. 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.

    3. After the configuration is complete, the common user needs to log in again for the configuration to take effect.