首页 > 解决方案 > AWS ElasticSearch 收缩 API 节点名称

问题描述

AWS ElasticSearch 的 AWS Docs 有一个关于收缩 API 的部分:

https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-supported-es-operations.html#es_version_api_notes-shrink

该示例显示了如何缩小:

{
  "settings": {
    "index.routing.allocation.require._name": "name-of-the-node-to-shrink-to",
    "index.blocks.read_only": true
  }
}
PUT https://domain.region.es.amazonaws.com/source-index/_settings
{
  "settings": {
    "index.routing.allocation.require._name": null,
    "index.blocks.read_only": false
  }
}

PUT https://domain.region.es.amazonaws.com/shrunken-index/_settings
{
  "settings": {
    "index.routing.allocation.require._name": null,
    "index.blocks.read_only": false
  }
}

我在哪里得到name-of-the-node-to-shrink-to,source-indexshrunken-index

标签: aws-elasticsearch

解决方案


对于收缩操作:

索引的所有主分片必须驻留在同一节点上。 https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html

name-of-the-node-to-shrink-to ”参数将索引的分片重新定位到此特定节点。

您可以使用cat 节点 API获取集群的节点名称:

GET /_cat/nodes?v&h=name

接下来,您要对其执行收缩操作的索引中的源索引。这个过程会创建一个新的目标索引,这将是你的shrunken-index

您将进行以下 API 调用来执行收缩操作:

POST /my_source_index/_shrink/my_target_index
{
  "settings": {
    "index.routing.allocation.require._name": null, 
    "index.blocks.write": null 
  }
}

您在 AWS 文档中看到的另外两个调用用于清除source-indexshrunken-index的分配要求

您也可以按照Elastic 的指南进行操作。


推荐阅读