Nginxプロセスごとに最大開くファイル数を設定

4169 ワード

文書ディレクトリ
  • 1.システムが開いているファイルを表示する最大制限数
  • 2.システムが開くファイルの最大制限数
  • を設定します.
  • 3.nginxオープンファイルの最大制限数
  • を設定します.
    1.システムオープンファイルを表示する最大制限数
    #           
    ulimit -a
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 7268
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 1024
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 7268
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    
    #              
    ulimit -n
    1024
    

    2.システムオープンファイルの最大制限数を設定する
    #                
    vi /etc/security/limits.conf
    #       
    ......
    * soft nofile 102400
    * hard nofile 102400
    
    
    #                
    ulimit -n 102400
    
    #    ,           
    #    
    init 6
    
    #    ,              
    ulimit -n
    102400
    

    3.nginxオープンファイルの最大制限数を設定する
    vi /usr/local/nginx/conf/nginx.conf
    user  nginx;
    worker_processes  4;
    worker_cpu_affinity 0001 0010 0100 1000;
    worker_rlimit_nofile 102400;
    ......
    
    #  nginx       
    nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    
    #    nginx
    nginx -s reload
    

    システムがファイルを開く最大制限数とnginxがファイルを開く最大制限数はできるだけ一致します.