Nginx提示Error: Too many open files的解决办法

栏目: 服务器 · Nginx · 发布时间: 8年前

内容简介:Nginx提示Error: Too many open files的解决办法

Nginx提示:Too many open files这种错误问题的原因是因为 linux 文件系统最大可打开文件数为1024,而你的nginx中的error.log出现大量的Too many open files,说明文件句柄不够用了所以就错误提示出来了。

如果nginx的error.log出现大量的Too many open files,说明文件句柄不够用了,这时候我们需要加大系统的文件句柄数和nginx的允许最大的连接数。

默认情况下linux文 件系统最大可打开文件数为1024,对于一个应用于生产环境下的服务器来说,这个设置太小,例如在用nginx做web服务器,当并发达到一定数量时,可以看到error.log里出现大量的“Nginx accept() failed (24: Too many open files)” 的错误。

正确设置Linux的ulimit -n的值的步骤如下:

1.先用命令ulimit -n 查看目前的值

2. vim /etc/security/limits.conf

建议把下面两项都设置为65535

* soft nofile 65535

* hard nofile 65535

(前面的*星号代表全局,针对所有的用户;nofile代表文件句柄数量;soft nofile的值不能超过hard nofile的值)

3.vim /usr/local/nginx/conf/nginx.conf

找到worker_connections ,把值调大一些,比如加个0

4.重启Linux系统

命令:shutdown -r now 表示立即重启

Nginx、Apache工作原理及Nginx为何比Apache高效 http://www.linuxidc.com/Linux/2017-03/141896.htm

CentOS 7下Nginx服务器的安装配置  http://www.linuxidc.com/Linux/2017-04/142986.htm

CentOS上安装Nginx服务器实现虚拟主机和域名重定向 http://www.linuxidc.com/Linux/2017-04/142642.htm

CentOS 6.8 安装LNMP环境(Linux+Nginx+MySQL+PHP) http://www.linuxidc.com/Linux/2017-04/142880.htm

Nginx服务的SSL认证和htpasswd认证 http://www.linuxidc.com/Linux/2017-04/142478.htm

Linux中安装配置Nginx及参数详解 http://www.linuxidc.com/Linux/2017-05/143853.htm

Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

CentOS 7.2下Nginx+PHP+MySQL+Memcache缓存服务器安装配置 http://www.linuxidc.com/Linux/2017-03/142168.htm

Nginx 的详细介绍 请点这里

Nginx 的下载地址 请点这里

本文永久更新链接地址 http://www.linuxidc.com/Linux/2017-05/144109.htm


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Distributed Systems

Distributed Systems

Sukumar Ghosh / Chapman and Hall/CRC / 2014-7-14 / USD 119.95

Distributed Systems: An Algorithmic Approach, Second Edition provides a balanced and straightforward treatment of the underlying theory and practical applications of distributed computing. As in the p......一起来看看 《Distributed Systems》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具