Nginx-too-many-open-files

Nginx-too-many-open-files

现象

Too many open files

处理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## 查看
ulimit -a
ulimit -n

## 修改-session生效
ulimit -n 65535

## 修改-永久生效-需重启
vi /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535

reboot

## 修改配置文件
events {
worker_connections 4096;
use epoll;
multi_accept on;
}

## 修改service参数
systemctl status nginx
vi /usr/lib/systemd/system/nginx.service
[Service]增加
LimitNOFILE=65535

## 重启nginx
systemctl daemon-reload
systemctl restart nginx

## 检查
ps -ef |grep nginx
cat /proc/31668/limits
Max open files 65535 65535 files