关于ElasticSearch的运行Bug
info:
1 | [1].max file descriptors [4096] for elasticsearch |
原因:
- 文件描述符fd太少:
切换到root用户 查看硬限制
1 | ulimit -Hn |
1 | vim /etc/security/limits.conf |
在limits配置文件中添加下面设置:
(adam是本地用户,替换你自己的)
1 | adam soft nofile 65536 |
退出用户重新登录,使配置生效
重新 ulimit -Hn 查看硬限制 会发现数值有4096改成65535
1 | vim /etc/security/limits.d/90-nproc.conf |
找到文件中的如下内容:
1 | soft nproc 1024 |
修改为:
1 | soft nproc 2048 |
接下来在/etc/sysctl.conf添加:
1 | vm.max_map_count=655360 |
并执行:
1 | sysctl -p |
参考文档 中是这么写的:
Elasticsearch uses a number of thread pools for different types of operations. It is important that it is able to create new threads whenever needed. Make sure that the number of threads that the Elasticsearch user can create is at least 4096.
意思就是说,ES是多线程处理任务的,为了确保ES可以正常运行,使用ES的用户可创建的线程数至少为4096
This can be done by setting ulimit -u 4096
as root before starting Elasticsearch, or by setting nproc
to 4096
in /etc/security/limits.conf
.
可以在root用户下使用 ulimit -u 4096
这个设置来配置生效。
The package distributions when run as services under systemd
will configure the number of threads for the Elasticsearch process automatically. No additional configuration is required.
如果使用systemd
作为系统服务来启动ES则无须额外配置。
- Title: 关于ElasticSearch的运行Bug
- Author: Cheems
- Created at : 2022-11-29 16:10:52
- Updated at : 2023-07-29 16:34:02
- Link: https://processmonitor.github.io/2022/11/29/ElasticSearch/
- License: This work is licensed under CC BY-NC-SA 4.0.