【问题标题】:Elasticsearch reindex - unknown_host_exceptionElasticsearch 重新索引 - unknown_host_exception
【发布时间】:2018-03-23 09:29:39
【问题描述】:

我尝试从远程服务器重新索引。 远程服务器上的 Elasticsearch 实例位于 nginx 代理后面,其 url 为 api.example.com/api/elasticsearch 端口 80。

我能够访问远程弹性搜索并执行查询。例如。

curl http://api.example.com:80/api/elasticsearch/_cat/indices?v

给出预期的结果。

但是,当我尝试从远程索引重新索引本地弹性搜索索引时,如下所示

curl -X POST http://elasticsearch:9200/_reindex -d '{ 
    "source": {
        "remote": { 
            "host": "http://api.example.com/api/elasticsearch:80"
        }, 
        "index": "alias_name" 
    }, 
    "dest": { 
        "index": "index_name" 
    }
}'

我收到一个错误:

{"error":{"root_cause":[{"type":"unknown_host_exception","reason":"api.example.com/api/elasticsearch: Name or service not known"}],"type":"unknown_host_exception","reason":"api.example.com/api/elasticsearch: Name or service not known"},"status":500}

【问题讨论】:

  • 在第一个例子中,地址字符串是“api.example.com:80/api/elasticsearch”,在第二个例子中是“api.example.com/api/elasticsearch:80”。为什么你改变了地址字符串中端口的位置?
  • 当我在重新索引查询中使用api.example.com:80/api/elasticsearch 作为主机时,我收到此错误:[host] 必须采用 [scheme]://[host]:[port] 的形式,但是是 [@ 987654324@
  • 我遇到了同样的问题。我的解决方法是在它们之间引入另一个nginx 代理,该代理在显式端口上侦听并转发呼叫。这是必要的,但效果很好。

标签: elasticsearch


【解决方案1】:

根据https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html的文档:

主机参数必须包含方案、主机、端口(例如 https://otherhost:9200) 和可选路径(例如 https://otherhost:9200/proxy)。用户名和密码参数 是可选的,当它们存在时,_reindex 将连接到 使用基本身份验证的远程 Elasticsearch 节点。一定要使用 https 时 使用基本身份验证或密码将以纯文本形式发送。

在您的情况下:“http://api.example.com:80/api/elasticsearch”或“http://api.example.com/api/elasticsearch

另外,最重要的是:

远程主机必须在 elasticsearch.yaml 中明确列入白名单 使用 reindex.remote.whitelist 属性。可以设置为逗号 允许的远程主机和端口组合的分隔列表(例如 otherhost:9200, another:9200, 127.0.10.:9200, localhost:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-14
    • 1970-01-01
    • 1970-01-01
    • 2017-01-25
    • 2014-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多