【问题标题】:elasticsearch setup on Gcloud VM failsGcloud VM 上的 elasticsearch 设置失败
【发布时间】:2019-05-07 08:37:23
【问题描述】:

我希望在 gcloud VM 上远程运行我的 elasticsearch,它被配置为在 127.0.0.1 的特定端口 9200 上运行。如何从这个 vm 之外的网站访问它?如果我在 yml 文件中将网络主机更改为 0.0.0.0,即使 9200 端口也无法访问。我该如何克服这个问题?

Changed network.host: [_site_ , _local_ , _global_ ]
_site_ = internal ip given by google cloud vm, 
_local_ = 127.0.0.1, 
_global_ = found using curl ifconfig.me, 
Opened a specific port (9200) and tried to connect with global IP address.

curl to the global ip gives 
>Output: Failed to connect to (_global_ ip) port 9200: connection refused.

【问题讨论】:

    标签: elasticsearch virtual-machine gcloud


    【解决方案1】:

    所以放 network.host:0.0.0.0 然后尝试允许 9200 和 9201 端口并重新启动 elasticsearch 服务。如果您使用的是 ubuntu 然后sudo service elasticsearch restart 然后通过执行curl -XGET 'http://localhost:9200?pretty' 进行检查。如果您是,请告诉我仍然面临任何问题。

    【讨论】:

    • 如果我使用 network.host 作为 0.0.0.0,同样的问题仍然存在
    • 我们使用相同的配置,并且工作正常。所以请检查 var/lib/elasticsearch/logs 中的日志。
    • @siddeshwar-raghavan 请在 network.host:10.21.xx.xxx 使用您的 ipAddress,这应该可以。
    • 仍然不适合我,我已经尝试了所有提到的内容。
    • 如果你能分享 yml 文件会很有帮助。
    【解决方案2】:

    elasticsearch.yml使用以下配置

    network.host: 0.0.0.0
    action.auto_create_index: false
    index.mapper.dynamic: false
    

    【讨论】:

      【解决方案3】:

      通过查看日志解决了这个问题,发现公网ip地址被重新映射到内部ip地址,因此network.host不能直接设置为外部ip。 Elasticsearch yml 配置如下:

      1. 'network.host: xx.xx.xxx.xx'设置为内部ip(google给出),
      2. 'http.cors.enabled: true',
      3. 'http.cors.allow-origin:"*",(不要在生产中使用 *,这是一个安全问题)
      4. 'discovery.type: single-node' 在我的情况下使其独立工作而不是在集群中

      现在可以使用 Google 提供的外部 IP 地址从虚拟机外部访问此沙盒版本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-08-06
        • 2019-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-07-11
        相关资源
        最近更新 更多