AWS ElasticSearch通过方案、主机和白名单重新索引远程集群问题



背景:

  • 我们在同一个AWS中有两个6.8版本的AWS ElasticSearch集群账户和地区
  • 我们需要将其中一个索引从集群1(源(重新索引到集群2(目标(

如ES 文档中所述,我尝试将API重新索引用于6.8

POST <https://endpoint of destination Elasticsearch>/_reindex 
{
"source": {
"remote": {
"host": "https://endpoint-of-source-elasticsearch-cluster-1.es.amazonaws.com"
},
"index": "source-index-name"
},
"dest": {
"index": "destination-index-name"
}
}

问题:

我的低于错误

{
"error": {
"root_cause": [
{
"type": "x_content_parse_exception",
"reason": "[8:3] [reindex] failed to parse field [source]"
}
],
"type": "x_content_parse_exception",
"reason": "[8:3] [reindex] failed to parse field [source]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "[host] must be of the form [scheme]://[host]:[port](/[pathPrefix])? but was [https://endpoint-of-source-elasticsearch-cluster-1.es.amazonaws.com]",
"caused_by": {
"type": "u_r_i_syntax_exception",
"reason": "The port was not defined in the [host]: https://endpoint-of-source-elasticsearch-cluster-1.es.amazonaws.com"
}
}
},
"status": 400
}

可能原因:

  1. 主机参数必须包含方案、主机、端口(例如。https://otherhost:9200)根据文件
  2. 远程主机必须使用reindex.mote.whitelist属性在elasticsearch.yaml中显式列入白名单

由于我使用的是AWS集群,我不确定如何遵循主机、发布或如何将集群列入白名单的方案,因为我不知道如何在AWS集群上进行这些更改。

请求帮助,如果有可用的解决方法。谢谢,

不幸的是,在AWS管理的Elasticsearch中,您将无法修改静态配置设置,如reindex.mote.whitelist参数,因为要配置reindex.hote.whitelit参数,需要修改Elasticsearch.yml文件。这是因为AWS ES管理服务,目前客户无法访问操作系统/文件系统。

作为替代方案,

  1. 您可以手动拍摄上一个域的快照,并将其还原到新域。与从远程重新索引相比,这种方法一次只影响一个域,即从中获取快照的域或将快照恢复到的域。

  2. 您还可以将Logstash与Elasticsearch输入和输出插件一起使用,从原始域中的索引中读取数据,并将其索引到任何其他/index域中。

AWS Elasticsearch v7.9现在支持远程重新索引,您只需要发出一个重新索引命令,例如:

POST <local-domain-endpoint>/_reindex
{
"source": {
"remote": {
"host": "https://remote-domain-endpoint:443"
},
"index": "remote_index"
},
"dest": {
"index": "local_index"
}
}

必须在远程域终结点的末尾添加443才能进行验证检查。

要验证索引是否已复制到本地域:

GET <local-domain-endpoint>/local_index/_search

如果远程索引所在的区域与您的本地域不同,请输入其区域名称,例如在以下示例请求中:

POST <local-domain-endpoint>/_reindex
{
"source": {
"remote": {
"host": "https://remote-domain-endpoint:443",
"region": "eu-west-1"
},
"index": "test_index"
},
"dest": {
"index": "local_index"
}
}

注:1-您必须在源地址中包含端口

2-使用AWS Elasticsearch,您不再需要像使用标准Elasticsearch那样将源IP/地址列入白名单,AWS Elastic search假设通过发出此命令,源地址是可信的。

Elasticsearch AWS文档可在此参考:https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/remote-reindex.html

从未使用aws-es的远程重新索引功能,它就是不起作用。

好的旧弹性转储永远不会失败:

elasticdump 
--input=https://xxxx.eu-west-1.es.amazonaws.com:443/index-name 
--output=https://xxxx.eu-west-1.es.amazonaws.com:443/index-name 
--type=data 
--limit=500 
--concurrency=5

要在没有sudo的情况下安装:

# Install node without root
curl -s https://webinstall.dev/node | bash
# Install elasticdump
npm install elasticdump -g

如果您从不是OpenSearch域本身的远程重新索引,请记住添加"external": true

POST _reindex?pretty=true&scroll=30m&wait_for_completion=false
{
"source": {
"remote": {
"host": "http://x.x.x.x:9200",
"external": true
},
"index": "from_index",
"size": 1000
},
"dest": {
"index": "to_index"
}
}

最新更新