我有一个Elasticsearch集群,其中包含10个节点,分为3个区域(A
,B
和C
)。
ES配置文件包含:
cluster.routing.allocation.awareness.force.zone.values = "A,B,C";
我有一个索引(
index1
),其中包含=~ 283674
大小为=~ 231MB
的docs。该索引的设置包含:
"number_of_replicas" : "2", "number_of_shards" : "5",
碎片似乎正确分布在区域中,但在单个区域中分布不均匀(请参见下表,例如,区域C | S =碎片,(P =主要| S =次要)
我该怎么做才能正确分配碎片?
++------+----------------------------------------------------+
||Zone A-----------------------------------------------------|
|| | ||
|| Node 1| S1 (P) ||
|| +-----------------------------------------------------+ ||
|| | ||
|| | S2 (S) S4 (S) ||
|| | ||
|| Node 2| ||
|| +-----------------------------------------------------+ ||
|| | ||
|| | ||
|| | S0 (S) S3 (S) ||
|| | ||
|| Node 3| ||
|-------+----------------------------------------------------|
||Zone B-----------------------------------------------------|
|| | ||
|| | S0 (P) ||
|| Node 4| ||
|| +-----------------------------------------------------+ ||
|| | ||
|| | ||
|| | S3 (P) S4 (P) ||
|| Node 5| ||
|| +-----------------------------------------------------+ ||
|| | ||
|| | ||
|| | S1 (S) S2 (S) ||
|| Node 6| ||
|-------+----------------------------------------------------|
||Zone C-----------------------------------------------------|
|| | ||
|| | S0 (S) S1 (S) S2 (P) S3 (S) S4 (S) ||
|| Node 7| ||
|| +------------------------------------------------------+ ||
|| | ||
|| | ||
|| | ||
|| Node 8| ||
|| +------------------------------------------------------+ ||
|| | ||
|| | ||
|| | ||
|| Node 9| ||
|| +------------------------------------------------------+ ||
|| | ||
|| | ||
|| - ||
|| Node 10 ||
|------------------------------------------------------------|
+------------------------------------------------------------+
最佳答案
我通过强制每个主机的分片数量和更改每个索引的主/次数量来解决此问题:
index.number_of_shards = "5";
index.number_of_replicas = "3";
index.routing.allocation.total_shards_per_node = "2";
这导致每个节点2个分片均匀分布在区域中。
关于elasticsearch - Elasticsearch路由分配意识和分片分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25530874/