【问题标题】:ElasticSearch instance not reachable from outside the server - Azure Windows 2012无法从服务器外部访问 ElasticSearch 实例 - Azure Windows 2012
【发布时间】:2019-06-07 23:18:11
【问题描述】:

我已在装有 Windows Server 2012 R2 的 Azure VM 中将 Elastic Search 2.3.0 设置为服务。我可以使用

从服务器内部访问弹性搜索实例
http://localhost:9200

但我无法从服务器外部访问。

我尝试了什么?

  • 仅出于测试目的,我已使 VM 在虚拟网络之外可用。
  • 在 Windows 防火墙设置中打开端口 9200 作为入站流量规则
  • 在 Azure 门户设置中添加了一个端点以打开端口 9200

也用 VM Classic 尝试过。

另外为了测试VM是否正常,我在那台机器上设置了IIS,打开了80端口。默认的IIS页面可以从外部访问。

我唯一没有尝试过的是在 Linux VM 中设置 ES。

我在 elasticsearch 日志中找不到任何内容。在浏览器 (Chrome) 上,网络中没有日志。它只是旋转,等待服务器,然后用“ERR_EMPTY_RESPONSE”捕捉。

请有做过这件事的人解释一下吗?

更新: 这是我在 netstat 中看到的:

TCP    127.0.0.1:9200         machine-name:0       LISTENING
TCP    127.0.0.1:9300         machine-name:0       LISTENING

【问题讨论】:

  • 在其他情况下,我们的团队使用 ES1.7.0,它工作得很好。困惑。

标签: azure elasticsearch windows2012


【解决方案1】:

从 ES 2.0 开始,elasticsearch 进程只有binds to localhost,这就解释了为什么可以从内部查询 ES 而不能从外部查询。

您需要在elasticsearch.yml 配置文件中更改以下设置:

network.host: 0.0.0.0

【讨论】:

  • 记得试试这个@Val。添加network.host: A.B.C.D,重启服务。仍然没有运气。而且它也无法通过 localhost 访问。也试过network.host: ["A.B.C.D", "127.0.0.1", "[::1]"]。也没有运气。
  • 在这种情况下,netstat 中端口 9200 和 9300 的条目会丢失。
  • 你需要使用真实的IP地址,A.B.C.D只是一个例子,但它需要是这样的:123.123.123.123
  • 请尝试使用值 0。
  • Thnx @Val,但没有运气。对于您的初始帖子,我在错误日志中看到了这一点:Exception in thread "main" BindTransportException[Failed to bind to [9300-9400]] ; nested: ChannelException[Failed to bind to: /<ip-address>:9400]; nested: Bind Exception[Cannot assign requested address: bind];
【解决方案2】:

我有同样的情况。查看日志

tail -f /var/log/elasticsearch/NODE.log

我看到了这个:

 [NODE_NAME] publish_address {10.XXX.XXX.XXX:9300}, bound_addresses {10.XXX.XXX.XXX:9300}
 [NODE_NAME] bound or publishing to a non-loopback address, enforcing bootstrap checks
 [NODE_NAME] node validation exception
 [1] bootstrap checks failed
 [1]: 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
 [NODE_NAME] stopping ...
 [NODE_NAME] stopped

解决方案:

使用以下命令修改 /etc/elasticsearch/elasticsearch.yml 行中的档案 discorvery seed:

discovery.seed_hosts: ["127.0.0.1", "[::1]"]

完成。

【讨论】:

    【解决方案3】:

    我建议将 network.host 设置为特殊值

    例如。

    network.host: [_local_, _site_]
    

    这对我有用。

    【讨论】:

    • 我可能是 ElasticSearch 菜鸟 @Amey,抱歉。你能再解释一下吗?例如,“特殊值”是什么意思?
    • elastic.co/guide/en/elasticsearch/reference/current/…。这是这个的参考链接。 本地 系统上的任何环回地址,例如 127.0.0.1。 site 系统上的任何站点本地地址,例如 192.168.0.1
    【解决方案4】:

    请注意,对我来说,只有在设置后才能成功

    http.host: 0.0.0.0
    

    而不是

    http.host: "localhost"
    

    【讨论】:

      【解决方案5】:

      使用 Elasticsearch 7.1.1 在 Windows server 2012 上为我解决了问题,在 C:\ProgramData\Elastic\Elasticsearch\config\elasticsearch.yml 中添加了以下配置:

      http.host: 0.0.0.0
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-10
        • 1970-01-01
        • 2023-03-22
        • 1970-01-01
        • 2018-04-30
        • 2020-09-16
        • 2018-01-22
        相关资源
        最近更新 更多