EC2 实例中的 ElasticSearch 连接超时

ElasticSearch Connection Timed Out in EC2 Instance

我正在 单个 EC2 实例 中设置 ELK Stack(由 ElasticSearch、LogStash 和 Kibana 组成)。 AWS EC2 实例。我正在关注 elastic.co 网站上的文档。

TL;DR;我无法从 Web URL 访问托管在 EC2 中的 ElasticSearch 界面。如何解决?

Type : m4.large
vCPU : 2
Memory : 8 GB
Storage: 25 GB (EBS)

注意:我已经在 VPC 和 中配置了 EC2 实例 和弹性 IP

我已经安装了所有 3 个组件。 ElasticSearch 和 LogStash 是 运行 作为服务,而 Kibana 是 运行 通过 kibana-7.10.1-linux-x86_64/ 目录中的命令 ./bin/kibana

当我使用

卷曲 ElasticSearch 端点时
curl http://localhost:9200 

我得到这个 JSON 输出。 (这意味着该服务是 运行 并且可以通过端口 9200 访问)。

但是,当我尝试通过浏览器访问相同的 URL 时,我收到一条错误消息

Connection Timed Out

这不是应该 return 与我上面提到的输出相同的 JSON 输出吗?

我已在此处附上 elasticsearch.yml 文件(托管在 gofile.io)。

这是 EC2 实例的入站规则。

EDIT :我尝试更改 network.host: 'localhost'network.host: 0.0.0.0 并重新启动服务,但这次我在启动服务时遇到错误。我附上了那个截图。

编辑 2:我已将 updated elasticsearch.yml 上传到 Gofile.org)。

问题出在您的 elasticsearch.yml 配置文件中的以下行:

node.name: node-1
network.host: 'localhost'

使用该配置,您的 ES 集群只能从同一主机访问,不能从外部访问。根据 official documentation,您需要指定 0.0.0.0 或特定的可公开访问的 IP 地址,否则将无法正常工作。

请注意,您还需要 configure the following two lines 才能正确形成集群:

discovery.seed_hosts: ["node-1-ip-address"]

# Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["node-1"]