We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
如果运行一段时间后,你发现服务器无法连接,同时ssh连上去后,查log的时候发现报很多这种错误Too many open files,那么是达到了系统的最大文件数
Too many open files
如果是ubuntu/centos均可修改/etc/sysctl.conf
/etc/sysctl.conf
找到fs.file-max这一行,修改其值为1024000,并保存退出。然后执行sysctl -p使其生效
fs.file-max
sysctl -p
打开文件/etc/security/limits.conf
/etc/security/limits.conf
添加两行:
* soft nofile 512000 * hard nofile 1024000
针对centos,还需要于/etc/pam.d/login检查有没有session required pam_limits.so,没有就加上 保存后,重启操作系统生效
针对ubuntu系统,你还需要额外的在运行前使用ulimit命令设置最大文件数,可使用附带的运行脚本。
如果使用supervisor进程守护,需要修改文件/etc/default/supervisor,添加一行: ulimit -n 512000 还可以在supervisord.conf的supervisord字段下添加minfds=512000来提升文件描述符限制 针对centos7,你还需要在/usr/lib/systemd/system/supervisord.service的service段添加 LimitNOFILE=512000 再启动你的服务
/etc/default/supervisor
ulimit -n 512000
LimitNOFILE=512000