如何防止分片从热节点迁移到温节点或冷节点?

How to prevent shard relocation from hot nodes to warm or cold nodes?

我有什么:

我想要什么:防止分片分配和重定位从热数据节点到热(和未来的冷)数据节点。

我尝试了什么:

我为所有索引模板设置了 "index.routing.allocation.require.data": "hot",因此新创建的索引不会分配给热数据节点以外的任何节点。这很好用。

无论如何,我无法限制分片从热节点迁移到热节点。目前我正在使用 "cluster.routing.allocation.exclude._ip" : "warm data node ip" 来防止从热数据节点重定位到暖数据节点。但是我可以通过这个过滤器使用 ILM 吗?

我也试过

PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.awareness.attributes": ["data"]
  }
}

PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.awareness.force.data.values": ["hot"]
  }
}

然后删除 "cluster.routing.allocation.exclude._ip" 过滤器。无论如何,分片都会从热数据节点迁移到热数据节点。我错过了什么?

我认为您错过了 ILM 策略中的分配意识。 你的暖相定义应该有

"allocate": {
   "require": {
        "data": "warm"
    }
}

从您的定义中删除它,它应该可以解决您的问题。

对我来说完全理解 ILM 的最好的文章是 https://www.elastic.co/blog/implementing-hot-warm-cold-in-elasticsearch-with-index-lifecycle-management 您可以在“针对 hot-warm-cold 优化您的 ILM 策略”

中找到完整示例

我必须更新旧事件的设置:

PUT my-index/_settings
{
  "index.routing.allocation.require.data": "hot"
}

如果更新索引模板,则不会更新某些索引模板下的索引。