Mac M1环境下Docker部署ES与Kibana提示服务未就绪求助
问题排查与解决步骤
针对你在Mac M1上用Docker部署Elasticsearch+Kibana时遇到的「Kibana server is not ready yet」问题,以下是具体排查点和修复方案:
1. Elasticsearch集群配置错误
你的ES配置中指定了多节点集群参数,但实际只启动了es01一个节点,导致ES无法完成集群初始化,服务处于异常状态,Kibana自然无法连接。
修复:修改ES的环境变量,切换为单节点模式:
environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.type=single-node # 启用单节点模式 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
删除原配置中的discovery.seed_hosts和cluster.initial_master_nodes参数。
2. ES与Kibana版本不匹配
当前ES使用7.16.2,Kibana使用7.16.1,Elastic Stack组件必须严格保持版本一致,否则会出现兼容性问题。
修复:将Kibana的镜像版本改为与ES一致:
image: docker.elastic.co/kibana/kibana:7.16.2
3. Kibana依赖容器启动而非服务就绪
depends_on仅保证ES容器启动,但ES服务需要时间初始化完成,Kibana提前启动会导致连接失败。
修复:给ES添加健康检查,让Kibana等待ES服务就绪后再启动:
- 给
es01添加健康检查配置:
es01: # ... 其他配置 healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"] interval: 10s timeout: 10s retries: 10
- 修改Kibana的
depends_on规则:
kibana: # ... 其他配置 depends_on: es01: condition: service_healthy
4. ELASTICSEARCH_HOSTS格式问题
当前配置的数组格式["http://es01:9200"]可能存在解析异常,改为字符串格式更稳妥:
environment: - ELASTICSEARCH_HOSTS=http://es01:9200
5. M1平台兼容性优化
你指定了platform: linux/amd64,但M1运行amd64镜像性能较差,7.16.x版本已支持arm64架构,可直接去掉该配置,使用原生arm镜像减少启动延迟。
修改后的完整docker-compose.yaml
version: '3.6' services: es01: image: docker.elastic.co/elasticsearch/elasticsearch:7.16.2 container_name: es01 environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.type=single-node - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms1g -Xmx1g" ulimits: memlock: soft: -1 hard: -1 volumes: - data01:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - elastic healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"] interval: 10s timeout: 10s retries: 10 kibana: image: docker.elastic.co/kibana/kibana:7.16.2 container_name: kibana ports: - 5601:5601 environment: - ELASTICSEARCH_HOSTS=http://es01:9200 depends_on: es01: condition: service_healthy networks: - elastic volumes: data01: driver: local networks: elastic: driver: bridge
验证步骤
- 清理现有容器和数据卷:
docker-compose down -v - 重新启动服务:
docker-compose up -d - 检查ES状态:执行
curl http://localhost:9200/_cluster/health,返回status为green或yellow即为正常 - 等待1-2分钟后访问
http://localhost:5601,确认Kibana正常加载
内容的提问来源于stack exchange,提问作者yeonsook kwak
相关产品推荐
相关产品推荐

