无法更改打开文件的限制

无法更改打开文件的限制

在ubuntu 14.04生产web服务器上,我进行如下设置:

/etc/security/limits.conf

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535

/etc/pam.d/common-session

session [default=1]                     pam_permit.so
session requisite                       pam_deny.so
session required                        pam_permit.so
session optional                        pam_umask.so
session required        pam_unix.so
session optional        pam_systemd.so
session required        pam_limits.so

/etc/pam.d/common-session-noninteractive

session [default=1]                     pam_permit.so
session requisite                       pam_deny.so
session required                        pam_permit.so
session optional                        pam_umask.so
session required        pam_unix.so
session required        pam_limits.so

即使重启后,ulimit -n 仍然输出 1024。下面的某个配置是否导致了这个问题?

/etc/sysctl.conf

net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_tw_reuse = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_syncookies = 1
net.core.somaxconn = 16384
fs.file-max = 65535

$ sysctl fs.file-max
fs.file-max = 65535

$ 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) 1026931
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) 1026931
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

答案1

检查之前是否没有其他进程启动并更改 ulimit,就像使用主管执行此操作一样:https://underyx.me/2015/05/18/raising-the-maximum-number-of-file-descriptors

相关内容