summaryrefslogtreecommitdiff
path: root/docs/reference/index-modules/allocation/filtering.asciidoc
blob: be45cd2a1ac87d69010f49b28d6a2b8bb2e6b650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
[[shard-allocation-filtering]]
=== Shard Allocation Filtering

Shard allocation filtering allows you to specify which nodes are allowed
to host the shards of a particular index.

NOTE: The per-index shard allocation filters explained below work in
conjunction with the cluster-wide allocation filters explained in
<<shards-allocation>>.

It is possible to assign arbitrary metadata attributes to each node at
startup.  For instance, nodes could be assigned a `rack` and a `group`
attribute as follows:

[source,sh]
------------------------
bin/elasticsearch -Ees.node.attr.rack=rack1 -Ees.node.attr.size=big  <1>
------------------------
<1> These attribute settings can also be specified in the `elasticsearch.yml` config file.

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:


[source,js]
------------------------
PUT test/_settings
{
  "index.routing.allocation.include.size": "big,medium"
}
------------------------
// CONSOLE
// TEST[s/^/PUT test\n/]

Alternatively, we can move the index `test` away from the `small` nodes with
an `exclude` rule:

[source,js]
------------------------
PUT test/_settings
{
  "index.routing.allocation.exclude.size": "small"
}
------------------------
// CONSOLE
// TEST[s/^/PUT test\n/]

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:

[source,js]
------------------------
PUT test/_settings
{
  "index.routing.allocation.include.size": "big",
  "index.routing.allocation.include.rack": "rack1"
}
------------------------
// CONSOLE
// TEST[s/^/PUT test\n/]

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

[horizontal]
`_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

All attribute values can be specified with wildcards, eg:

[source,js]
------------------------
PUT test/_settings
{
  "index.routing.allocation.include._ip": "192.168.2.*"
}
------------------------
// CONSOLE
// TEST[skip:indexes don't assign]