问题描述
使用./elasticsearch
启动 es 的时候报以下错误
ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max number of threads [3795] for user [elastic] is too low, increase to at least [4096]
解决
该报错是因为 elasticsearch 启动的时候要求当前用户最大线程数至少为 4096 个线程,而操作系统限制该用户最大线程数为 3795,只需要修改当前用户的最大线程数即可。可以使用ulimit -a
查看当前用户允许的最大线程数
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3795
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 3795
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
可以看到 max user processes 确实为 3795
在 Linux 中,用户允许的最大线程数的配置文件为/etc/security/limits.conf
,我们需要在该配置文件中添加下面配置
elasticsearch - nproc 65535
elasticsearch 是我启动 es 的用户,需要根据实际情况改为你的启动用户
该配置会在下个会话中生效,所以我们还需要退出 elasticsearch 用户重新登录,再使用ulimit -a
查看当前用户允许的最大线程数
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3795
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 65535
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
可以看到,此时允许的最大线程数已经修改为 65535 了,接着执行./elasticsearch
脚本就能正常启动 es 了
参考:
elasticsearch 官网
Linux CentOS7 单机部署elasticsearch-7.2.0