https://www.elastic.co/guide/en/elasticsearch/reference/7.7/index-modules-allocation.html
Index级别分片分配过滤器
node节点的配置中,可以配置attribute打标签,例如 node.attr.size: medium
Index的设置可以使用对应的attribute条件进行分配,例如
PUT test/_settings 分配给size是big或medium的节点 { "index.routing.allocation.include.size": "big,medium" }
PUT test/_settings 分配给size是big且rack是rack1的节点 { "index.routing.allocation.include.size": "big", "index.routing.allocation.include.rack": "rack1" }
条件匹配规则
index.routing.allocation.include.{attribute} 至少符合1个,逗号分割
index.routing.allocation.require.{attribute} 全部符合,逗号分割
index.routing.allocation.exclude.{attribute} 全部都不能符合,逗号分割
已内置的attr有:
|
Match nodes by node name |
|
Match nodes by host IP address (IP associated with hostname) |
|
Match nodes by publish IP address |
|
Match either |
|
Match nodes by hostname |
|
Match nodes by node id |
条件匹配可以使用通配符
PUT test/_settings { "index.routing.allocation.include._ip": "192.168.2.*" }