elasticsearch - Elasticsearch路由分配意识和分片分配

标签 elasticsearch

我有一个Elasticsearch集群,其中包含10个节点,分为3个区域(ABC)。

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/

相关文章:

java - Elasticsearch:通过 Java 客户端发送 JSON 查询字符串?

elasticsearch - ElasticSearch:搜索并返回嵌套类型

node.js - ElasticSearch-多次匹配查询,即使数据在那里也没有返回命中值-NodeJS

elasticsearch - 如何停止 logstash 将 logstash 日志写入 syslog?

elasticsearch - Elasticsearch不在术语查询中搜索字段

elasticsearch - 带空格的短语中的通配符/正则表达式

elasticsearch - 如何禁用 elasticsearch 中的自动索引创建?

elasticsearch - Grok模式-用于逗号分隔的数据

python - 搜索嵌套文档

node.js - 将 Elasticsearch 与 PostgreSQL 集成,同时将 Sails.js 与 Waterline ORM 结合使用