Elasticsearch Index Shard Allocation索引分片分配

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有:

_name

Match nodes by node name

_host_ip

Match nodes by host IP address (IP associated with hostname)

_publish_ip

Match nodes by publish IP address

_ip

Match either _host_ip or _publish_ip

_host

Match nodes by hostname

_id

Match nodes by node id

 

条件匹配可以使用通配符

PUT test/_settings
{
  "index.routing.allocation.include._ip": "192.168.2.*"
}

 

上一篇:ElasticSearch 学习1:linux 安装 ElasticSearch7.6.1


下一篇:码农故事:Tina的运动会方阵哲学