socket() failed (24: Too many open files)

 

这个错误因为超出了ulimit nofile

当前bash的这样修改:

[root@A06 ~]# ulimit -n
200
[root@A06 ~]# ulimit -n 2000000
[root@A06 ~]# ulimit -n
2000000

 

systemd 启动的程序这样修改

[root@A06 ~]# cat /usr/lib/systemd/system/nginx.service |grep -C1 -i nofile
[Service]
LimitNOFILE=2048000
Type=forking

 

全局的配置这样改

[root@A06 ~]# cat /etc/security/limits.d/90-nofile.conf
* soft nofile 2000000
* hard nofile 2000000

 

全局配置不能超过这个值,否则会出现可怕的事情,登陆不进去系统,显示器也不能。

局部配置大于了不生效。

[root@A06 ~]# cat /proc/sys/fs/nr_open
10000000

 

sysctl可以改

sysctl -w fs.nr_open=10000000

 

posted on 2024-12-04 15:24  toong  阅读(214)  评论(0)    收藏  举报