连接到上游时 socket() 失败(24:打开的文件过多)

连接到上游时 socket() 失败(24:打开的文件过多)
fs.file-max = 70000

添加到/etc/sysctl.conf

nginx       soft    nofile   10000
nginx       hard    nofile  30000

添加到/etc/security/limits.conf

worker_rlimit_nofile 30000;

将此添加到/etc/nginx/nginx.conf导致重新加载 nginx 时出现问题:

# systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.

/etc/nginx/nginx.conf添加外观后的文件:

#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;


#this is added
worker_rlimit_nofile 30000;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  8192;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

更新: 编辑 nginx.service 文件

systemctl edit --full nginx.service

添加并LimitNOFILE=10000 没有帮助

解决了

我必须添加worker_rlimit_nofile 30000;到文件中/etc/nginx/ulimit.global_params

相关内容