通过命令ulimit -a查看的open files参数的修改:

[root@nginx ~]# 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) 7697

max locked memory       (kbytes, -l) 64

max memory size         (kbytes, -m) unlimited

open files                      (-n) 65535

pipe size            (512 bytes, -p) 8

POSIX message queues     (bytes, -q) 819200

real-time priority              (-r) 0

stack size              (kbytes, -s) 10240

cpu time               (seconds, -t) unlimited

max user processes              (-u) 1024

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

  1. 通过命令ulimit -n number可以直接修改,但是修改的只是当前会话的open files,重新打开一个连接查看的open files还是原来的。

  2. 修改配置文件/etc/security/limits.conf 添加

    *       soft    nofile  65535

    *       hard    nofile  65535

    注意格式,会立即生效,重新连接一下就可以看到了,ulimit -a。

不需要重启,就会立即生效的。