没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
一、访问 Nginx 时,报错:"accept() failed (24: Too many open
les)"
原因时:nginx 的连接数超过了系统设定的最大值造成的.
处理办法如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@kvm-server nginx]# ulimit -n
1024
[root@kvm-server nginx]# ulimit -n 655360 #把打开文件数设置足够大,这是临时修改方案
[root@kvm-server nginx]# ulimit -n
655360
同时修改 nginx.conf 文件,添加下面内容,然后重启 nginx
worker_rlimit_nofile 655350;
这样就可以解决 Nginx 连接过多的问题,Nginx 就可以支持高并发。
另外,ulimit-n 还会影响到 mysql 的并发连接数。提高文件连接数设置,也能提高 mysql 并发。
注意: 用 ulimit-n 655360 修改只对当前的 shell 有效,退出后失效。所以,需要永久性修改
永久生效方法:
修改/etc/security/limits.conf,在文件底部添加:
* soft nofile 655360
* hard nofile 655360
星号代表全局, soft 为软件,hard 为硬件,nofile 为这里指可打开文件数。
另外,要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。
查看/etc/pam.d/login文件中有:
session required/lib/security/pam_limits.so
这样,问题就迎刃而解了!
ulimit:设置最大进程数和最大文件打开数, 这个一般是系统优化的必要手段.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1) 临时修改
为了优化 linux 性能,可能需要修改这个最大值。临时修改的话 ulimit-n 655360 就可以了,重启后失效。
[root@localhost ~]# ulimit -n
1024
[root@localhost ~]# ulimit -n 655360
[root@localhost ~]# ulimit -n
655360
2) 永久修改
修改/etc/security/limits.conf 文件, 在文件末尾添加
[root@localhost ~]# vim /etc/security/limits.conf
* soft nofile 655360
* hard nofile 655360
资源评论
sxluohuan91
- 粉丝: 0
- 资源: 25
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功