跳转至

Docker 运行 Elasticsearch 报错 bootstrap checks failed 的解决方案

约 186 个字 3 行代码 预计阅读时间 1 分钟

情形

1
2
3
4
ERROR: [2] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2]: 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
ERROR: Elasticsearch did not exit normally - check the logs at /usr/share/elasticsearch/logs/docker-elasticsearch.log

原因及解决方案

设置的虚拟内存太低

  1. /etc/security/limits.conf 中添加:
    * soft nofile 65536
    * hard nofile 65536
    
  2. /etc/sysctl.conf 中添加:
    vm.max_map_count=655360
    
  3. 运行命令使其配置生效
    sysctl ‐p
    
  4. restart 容器

缺少默认配置

缺少默认配置,至少需要配置discovery.seed_hosts / discovery.seed_providers / cluster.initial_master_nodes中的一个参数.

  • discovery.seed_hosts: 集群主机列表
  • discovery.seed_providers: 基于配置文件配置集群主机列表
  • cluster.initial_master_nodes: 启动时初始化的参与选主的node,生产环境必填

解决方案

编辑配置文件,添加:

discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["node-1"]

来源