Shard Allocation Filtering
editShard Allocation Filtering
editShard allocation filtering allows you to specify which nodes are allowed to host the shards of a particular index.
The per-index shard allocation filters explained below work in conjunction with the cluster-wide allocation filters explained in Cluster Level Shard Allocation.
It is possible to assign arbitrary metadata attributes to each node at
startup. For instance, nodes could be assigned a rack
and a size
attribute as follows:
These metadata attributes can be used with the
index.routing.allocation.*
settings to allocate an index to a particular
group of nodes. For instance, we can move the index test
to either big
or
medium
nodes as follows:
PUT test/_settings { "index.routing.allocation.include.size": "big,medium" }
Alternatively, we can move the index test
away from the small
nodes with
an exclude
rule:
PUT test/_settings { "index.routing.allocation.exclude.size": "small" }
Multiple rules can be specified, in which case all conditions must be
satisfied. For instance, we could move the index test
to big
nodes in
rack1
with the following:
PUT test/_settings { "index.routing.allocation.include.size": "big", "index.routing.allocation.include.rack": "rack1" }
If some conditions cannot be satisfied then shards will not be moved.
The following settings are dynamic, allowing live indices to be moved from one set of nodes to another:
-
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.
These special attributes are also supported:
|
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 |
All attribute values can be specified with wildcards, eg:
PUT test/_settings { "index.routing.allocation.include._ip": "192.168.2.*" }