You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在EC2实例配置ElasticSearch与LogStash时遇master_not_discovered_exception问题

问题分析与解决

问题根源

你遇到的master_not_discovered_exception错误,核心原因是Elasticsearch 7.x及以上版本的单节点集群,必须正确配置cluster.initial_master_nodes参数。

你的当前配置中:

discovery.seed_hosts : []
cluster.initial_master_nodes :  []

虽然curl http://localhost:9200能返回节点基础信息,但集群并未完成主节点选举,处于异常状态,因此无法执行需要主节点协调的操作(比如查看索引列表)。

解决方案

  1. 修改elasticsearch.yaml配置
    打开配置文件,将cluster.initial_master_nodes设置为当前节点的名称(从你之前的curl结果可知节点名为ip-10-0-0-89):

    node.data : true
    network.host : 0.0.0.0
    discovery.seed_hosts : []
    cluster.initial_master_nodes : ["ip-10-0-0-89"]
    

    如果你更倾向用IP,也可以设置为["10.0.0.89"],确保和节点实际绑定的IP一致。

  2. 重启Elasticsearch服务
    执行重启命令(deb包安装环境示例):

    sudo systemctl restart elasticsearch
    
  3. 验证修复结果
    再次执行索引查看命令:

    sudo curl -XGET 'localhost:9200/_cat/indices?v&pretty'
    

    此时应该能正常返回索引列表(无数据时会显示为空,但不会再返回503错误)。

关于另一台实例正常的原因

另一台EC2实例能正常运行,大概率是它的cluster.initial_master_nodes参数配置正确(指定了自身节点名或IP),符合Elasticsearch 7.x的集群初始化要求。

内容的提问来源于stack exchange,提问作者Eby

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 21:15:43