elasticsearch max file descriptors launch failed

因为es是使用的局域网环境,所以就打算直接监听0.0.0.0 这样内网的服务都可以访问到它。
但是在设置network.host: 0.0.0.0 这一参数之后,发现没有9200端口的监听了。

最后结合着日志和部分现有的方法解决这个问题。遂在这里记下来。

日志报错

使用之前的默认测试配置应该是对系统的参数是没有要求的,所以可以成功启动。但是修改了监听之后就无法启动了。检查日志:

[2019-09-14T04:20:51,040][INFO ][o.e.b.BootstrapChecks    ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

所以很明显有以上三个问题,一一解决即可。

解决问题

三个问题,三个解决,前面两个很眼熟。

problem 1

是在security里设置用户的 最大线程数和最大文件句柄数。使用 ulimit检查了一下没问他,后来才意识到,es是使用user账户运行的。

ulimit -Sn
ulimit -Hn
ulimit -Su
ulimit -Hu

修改配置 /etc/security/limits.conf 里的限制如下:

rms soft nofile 65536
rms hard nofile 131072
* soft nproc 2048
* hard nproc 4096

至此解决问题1

problem 2

配置/etc/sysctl.conf 添加以下内核参数:

vm.max_map_count=262144

至此解决问题2

problem 3

问题3的话,改一下配置文件就好,无需赘述了。至此解决问题3

踩坑

那么真的就这么顺利吗?显然不是,上面的配置解决了13的问题,但是那该4096是的限制始终我无法改变。使用了root和user的权限来对ulimit来进行确认都没有问题,而且直接使用 rms 遮盖账户进行es的运行也是没有问题。

所以排除法,问题出在了 supervisor上。检查其配置文件,果真发现了在默认配置里有一行内容:

;minfds=1024                 ; (min. avail startup file descriptors;default 1024)

应该就是这里限制了使用 sp启动的进程的nofile,所以就修改至65536.再次使用supervisor来进行es的进程启动,成功启动。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注