使用docker部署Elasticsearch报错:ERROR: Elasticsearch exited unexpectedly, with exit code 78

报错信息

笔者参考Elasticsearch的官网链接部署docker版本的Es报错。报错信息如下:

{"@timestamp":"2024-01-16T08:53:50.091Z", "log.level":"ERROR", "message":"node validation exception\n[1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch. For more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.11/bootstrap-checks.html]\nbootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]; for more information see [https://www.elastic.co/guide/en/elasticsearch/reference/8.11/_maximum_map_count_check.html]", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.bootstrap.Elasticsearch","elasticsearch.node.name":"aa7f36766585","elasticsearch.cluster.name":"docker-cluster"}

使用docker部署Elasticsearch报错:ERROR: Elasticsearch exited unexpectedly, with exit code 78_第1张图片

原因

vm.max_map_count 是一个 Linux 内核参数,用于设置进程的最大内存映射数量。在一些特定的应用场景中,例如运行 Elasticsearch,需要适当地调整 vm.max_map_count 的值。

# 查看
sysctl vm.max_map_count
# 临时修改值
sudo sysctl -w vm.max_map_count=<value>

解决方案

下文的262144是报错信息中提示的最小值。

  • 临时解决方案
sudo sysctl -w vm.max_map_count=262144
  • 永久方案
    如果你想永久修改 vm.max_map_count 的值,可以编辑 /etc/sysctl.conf 文件,在文件的末尾添加一行:
vm.max_map_count=262144

然后加载配置

sudo sysctl -p

这将重新加载 /etc/sysctl.conf 中的配置,并将新的 vm.max_map_count 值应用到系统中。请记住,在修改系统参数时要小心,并确保你了解修改的目的以及潜在的影响。

参考

Elasticsearch Container Stopped with Exit 78 state in Ubuntu 18.04 #1699

后记

天灵灵地灵灵,快把bug收了吧

你可能感兴趣的:(docker,elasticsearch,bug)