碎片配置过滤允许您指定哪些节点允许主机的一个特定的索引碎片

可以在启动时为每个节点分配任意元数据属性。 例如,可以给节点分配一个 rack 和一个 size 属性,如下所示:

bin/elasticsearch -Enode.attr.rack=rack1 -Enode.attr.size=big

These attribute settings can also be specified in the elasticsearch.yml config file.

这些元数据属性可以与 index.routing.allocation.* 一起使用,以便将索引分配给特定的节点组。例如,我们可以将索引 test 移动到大或中节点,如下所示

PUT test/_settings
{
  "index.routing.allocation.include.size": "big,medium"
}

或者排除 test 索引 进入 small 节点集群中

PUT test/_settings { "index.routing.allocation.exclude.size": "small" }

可以指定多个规则,在这种情况下必须满足所有条件。 例如,我们可以移动 test 索引 到 rack1 组中的 big 节点中

PUT test/_settings
{
  "index.routing.allocation.include.size": "big",
  "index.routing.allocation.include.rack": "rack1"
}

以下设置是动态的,允许将活索引从一组节点移动到另一组节点:

index.routing.allocation.include.{attribute} Assign the index to a node whose {attribute} has at least one of the comma-separated values.

index.routing.allocation.require.{attribute} Assign the index to a node whose {attribute} has all of the comma-separated values.

index.routing.allocation.exclude.{attribute} Assign the index to a node whose {attribute} has none of the comma-separated values.

这些特殊属性也得到了支持:

_name 按节点名称匹配节点

_host_ip 匹配节点的主机的IP地址(IP与主机名)

_publish_ip 通过发布IP地址匹配节点

_ip 匹配任何一个 _host_ip _publish_ip

_host 匹配节点的主机名

所有的属性值可以指定通配符:

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

results matching ""

    No results matching ""