首页 > 代码库 > Notice : Soft open files now is 1024, We recommend greater than 10000

Notice : Soft open files now is 1024, We recommend greater than 10000

在研究 workerman 时, 报了这个错误, 感觉只是个notice级别的, 就一直给忽略掉了, 今天有时间, 就查了一下.

其实本质就是 ulimit 这个命令

打开一个命令行, 输入 ulimit -a

可以查看到, 当前系统所有的限制

[root@butterfly ~]# 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) 3858
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) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 3858
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

默认 open files 是 1024 

打开这个文件 /etc/security/limits.conf 

添加如下两行 

* soft nofile 99999
* hard nofile 99999

重启一下系统,

再输入 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) 30690
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 99999
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) 30690
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

就ok了

点击查看关于此命令详细介绍 

Notice : Soft open files now is 1024, We recommend greater than 10000