禁用分配的单个副本的意外 ElasticSearch 分片分配

Unexpected ElasticSearch shard allocation for a single replica with allocation disabled

我们有一个双节点环境,有些数据我们只想存储在主节点上(因为另一个节点的可用性不高)。

为此,我将副本数设置为 0,还在我们不希望发生分片分配的索引上设置以下属性:

"index.routing.allocation.enable": "none",
"index.routing.allocation.rebalance": "none"

我的期望是这样做会将所有 5 个分片保留在主节点上。但是,一旦我将工作节点连接到环境,每个索引中的 2 或 3 个分片就会移动到工作节点!我怎样才能阻止这种情况发生并将指定索引的所有分片保留在主节点上?谢谢!

我认为您需要分片分配过滤来指定允许哪些节点托管特定索引的分片。

https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-allocation-filtering.html