zoukankan      html  css  js  c++  java
  • 修改nginx 进程最大文件句柄数

    修改nginx 进程最大文件句柄数

    1. 修改 cat /etc/sysctl.conf 中 fs.file-max参数
    fs.file-max=65535


    执行 sysctl -p 让修改的内核参数生效


    2.修改linux系统参数。追加下面内容到 /etc/security/limits.conf 文件
    *  soft  nofile  65535
    *  hard  nofile  65535


    命令如下:
    echo "* soft nofile 65535" >> /etc/security/limits.conf
    echo "* hard nofile 65535" >> /etc/security/limits.conf

    3. 修改 nginx systemd 启动参数


    cat /usr/lib/systemd/system/nginx.service


    [Unit]
    Description=The nginx HTTP and reverse proxy server
    After=network.target remote-fs.target nss-lookup.target
    [Service]
    Type=forking
    PIDFile=/run/nginx.pid
    # Nginx will fail to start if /run/nginx.pid already exists but has the wrong
    # SELinux context. This might happen when running `nginx -t` from the cmdline.
    # https://bugzilla.redhat.com/show_bug.cgi?id=1268621
    ExecStartPre=/usr/bin/rm -f /run/nginx.pid
    ExecStartPre=/usr/sbin/nginx -t
    ExecStart=/usr/sbin/nginx
    ExecReload=/bin/kill -s HUP $MAINPID
    KillSignal=SIGQUIT
    TimeoutStopSec=5
    KillMode=process
    PrivateTmp=true
    LimitNOFILE=65535 // 添加这一行


    [Install]
    WantedBy=multi-user.target


    4. 重新启动 nginx 进程
    systemctl daemon-reload
    systemctl restart nginx

    5. 查看nginx 进程 pid
    ps aux|grep nginx
    root 16257 0.0 0.0 123140 2488 ? Ss 16:48 0:00 nginx: master process /usr/sbin/nginx
    nginx 16258 0.2 0.0 123588 4060 ? S 16:48 0:02 nginx: worker process
    nginx 16259 0.3 0.0 123588 4052 ? S 16:48 0:03 nginx: worker process
    nginx 16260 1.8 0.0 123984 4552 ? S 16:48 0:16 nginx: worker process
    nginx 16261 0.6 0.0 123588 4056 ? S 16:48 0:06 nginx: worker process


    6. 查看进程的 limits 数值, 其中 max open files 已经调整为 65535

    cat /proc/16257/limits
    Limit Soft Limit Hard Limit Units
    Max cpu time unlimited unlimited seconds
    Max file size unlimited unlimited bytes
    Max data size unlimited unlimited bytes
    Max stack size 8388608 unlimited bytes
    Max core file size 0 unlimited bytes
    Max resident set unlimited unlimited bytes
    Max processes 31217 31217 processes
    Max open files 65535 65535 files
    Max locked memory 65536 65536 bytes
    Max address space unlimited unlimited bytes
    Max file locks unlimited unlimited locks
    Max pending signals 31217 31217 signals
    Max msgqueue size 819200 819200 bytes
    Max nice priority 0 0
    Max realtime priority 0 0
    Max realtime timeout unlimited unlimited us

  • 相关阅读:
    异步FIFO的Verilog实现
    二进制格雷码与二进制自然码
    握手协议
    电容充放电和开关电容
    Vivado自定义IP封装流程
    【转】warning 之 [IP_Flow 19-3153]
    【转】mipi-csi-2解读
    版本管理-link
    [转载]yuv和yCbCr的差异
    【转】用verilog实现RGB格式图像到YCbCr或YUV格式的转换及其验证方法 (RGB2YCrCb)(RGB2YUV)
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/15250422.html
Copyright © 2011-2022 走看看