cluster.asciidoc 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. [[modules-cluster]]
  2. == Cluster
  3. [float]
  4. [[shards-allocation]]
  5. === Shards Allocation
  6. Shards allocation is the process of allocating shards to nodes. This can
  7. happen during initial recovery, replica allocation, rebalancing, or
  8. handling nodes being added or removed.
  9. The following settings may be used:
  10. `cluster.routing.allocation.allow_rebalance`::
  11. Allow to control when rebalancing will happen based on the total
  12. state of all the indices shards in the cluster. `always`,
  13. `indices_primaries_active`, and `indices_all_active` are allowed,
  14. defaulting to `indices_all_active` to reduce chatter during
  15. initial recovery.
  16. `cluster.routing.allocation.cluster_concurrent_rebalance`::
  17. Allow to control how many concurrent rebalancing of shards are
  18. allowed cluster wide, and default it to `2`.
  19. `cluster.routing.allocation.node_initial_primaries_recoveries`::
  20. Allow to control specifically the number of initial recoveries
  21. of primaries that are allowed per node. Since most times local
  22. gateway is used, those should be fast and we can handle more of
  23. those per node without creating load.
  24. `cluster.routing.allocation.node_concurrent_recoveries`::
  25. How many concurrent recoveries are allowed to happen on a node.
  26. Defaults to `2`.
  27. `cluster.routing.allocation.disable_new_allocation`::
  28. Allows to disable new primary allocations. Note, this will prevent
  29. allocations for newly created indices. This setting really make
  30. sense when dynamically updating it using the cluster update
  31. settings API.
  32. `cluster.routing.allocation.disable_allocation`::
  33. Allows to disable either primary or replica allocation (does not
  34. apply to newly created primaries, see `disable_new_allocation`
  35. above). Note, a replica will still be promoted to primary if
  36. one does not exist. This setting really make sense when
  37. dynamically updating it using the cluster update settings API.
  38. `cluster.routing.allocation.disable_replica_allocation`::
  39. Allows to disable only replica allocation. Similar to the previous
  40. setting, mainly make sense when using it dynamically using the
  41. cluster update settings API.
  42. `indices.recovery.concurrent_streams`::
  43. The number of streams to open (on a *node* level) to recover a
  44. shard from a peer shard. Defaults to `3`.
  45. [float]
  46. [[allocation-awareness]]
  47. === Shard Allocation Awareness
  48. Cluster allocation awareness allows to configure shard and replicas
  49. allocation across generic attributes associated the nodes. Lets explain
  50. it through an example:
  51. Assume we have several racks. When we start a node, we can configure an
  52. attribute called `rack_id` (any attribute name works), for example, here
  53. is a sample config:
  54. ----------------------
  55. node.rack_id: rack_one
  56. ----------------------
  57. The above sets an attribute called `rack_id` for the relevant node with
  58. a value of `rack_one`. Now, we need to configure the `rack_id` attribute
  59. as one of the awareness allocation attributes (set it on *all* (master
  60. eligible) nodes config):
  61. --------------------------------------------------------
  62. cluster.routing.allocation.awareness.attributes: rack_id
  63. --------------------------------------------------------
  64. The above will mean that the `rack_id` attribute will be used to do
  65. awareness based allocation of shard and its replicas. For example, lets
  66. say we start 2 nodes with `node.rack_id` set to `rack_one`, and deploy a
  67. single index with 5 shards and 1 replica. The index will be fully
  68. deployed on the current nodes (5 shards and 1 replica each, total of 10
  69. shards).
  70. Now, if we start two more nodes, with `node.rack_id` set to `rack_two`,
  71. shards will relocate to even the number of shards across the nodes, but,
  72. a shard and its replica will not be allocated in the same `rack_id`
  73. value.
  74. The awareness attributes can hold several values, for example:
  75. -------------------------------------------------------------
  76. cluster.routing.allocation.awareness.attributes: rack_id,zone
  77. -------------------------------------------------------------
  78. *NOTE*: When using awareness attributes, shards will not be allocated to
  79. nodes that don't have values set for those attributes.
  80. [float]
  81. [[forced-awareness]]
  82. === Forced Awareness
  83. Sometimes, we know in advance the number of values an awareness
  84. attribute can have, and more over, we would like never to have more
  85. replicas then needed allocated on a specific group of nodes with the
  86. same awareness attribute value. For that, we can force awareness on
  87. specific attributes.
  88. For example, lets say we have an awareness attribute called `zone`, and
  89. we know we are going to have two zones, `zone1` and `zone2`. Here is how
  90. we can force awareness one a node:
  91. [source,js]
  92. -------------------------------------------------------------------
  93. cluster.routing.allocation.awareness.force.zone.values: zone1,zone2
  94. cluster.routing.allocation.awareness.attributes: zone
  95. -------------------------------------------------------------------
  96. Now, lets say we start 2 nodes with `node.zone` set to `zone1` and
  97. create an index with 5 shards and 1 replica. The index will be created,
  98. but only 5 shards will be allocated (with no replicas). Only when we
  99. start more shards with `node.zone` set to `zone2` will the replicas be
  100. allocated.
  101. [float]
  102. ==== Automatic Preference When Searching / GETing
  103. When executing a search, or doing a get, the node receiving the request
  104. will prefer to execute the request on shards that exists on nodes that
  105. have the same attribute values as the executing node.
  106. [float]
  107. ==== Realtime Settings Update
  108. The settings can be updated using the <<cluster-update-settings,cluster update settings API>> on a live cluster.
  109. [float]
  110. [[allocation-filtering]]
  111. === Shard Allocation Filtering
  112. Allow to control allocation if indices on nodes based on include/exclude
  113. filters. The filters can be set both on the index level and on the
  114. cluster level. Lets start with an example of setting it on the cluster
  115. level:
  116. Lets say we have 4 nodes, each has specific attribute called `tag`
  117. associated with it (the name of the attribute can be any name). Each
  118. node has a specific value associated with `tag`. Node 1 has a setting
  119. `node.tag: value1`, Node 2 a setting of `node.tag: value2`, and so on.
  120. We can create an index that will only deploy on nodes that have `tag`
  121. set to `value1` and `value2` by setting
  122. `index.routing.allocation.include.tag` to `value1,value2`. For example:
  123. [source,js]
  124. --------------------------------------------------
  125. curl -XPUT localhost:9200/test/_settings -d '{
  126. "index.routing.allocation.include.tag" : "value1,value2"
  127. }'
  128. --------------------------------------------------
  129. On the other hand, we can create an index that will be deployed on all
  130. nodes except for nodes with a `tag` of value `value3` by setting
  131. `index.routing.allocation.exclude.tag` to `value3`. For example:
  132. [source,js]
  133. --------------------------------------------------
  134. curl -XPUT localhost:9200/test/_settings -d '{
  135. "index.routing.allocation.exclude.tag" : "value3"
  136. }'
  137. --------------------------------------------------
  138. `index.routing.allocation.require.*` can be used to
  139. specify a number of rules, all of which MUST match in order for a shard
  140. to be allocated to a node. This is in contrast to `include` which will
  141. include a node if ANY rule matches.
  142. The `include`, `exclude` and `require` values can have generic simple
  143. matching wildcards, for example, `value1*`. A special attribute name
  144. called `_ip` can be used to match on node ip values. In addition `_host`
  145. attribute can be used to match on either the node's hostname or its ip
  146. address.
  147. Obviously a node can have several attributes associated with it, and
  148. both the attribute name and value are controlled in the setting. For
  149. example, here is a sample of several node configurations:
  150. [source,js]
  151. --------------------------------------------------
  152. node.group1: group1_value1
  153. node.group2: group2_value4
  154. --------------------------------------------------
  155. In the same manner, `include`, `exclude` and `require` can work against
  156. several attributes, for example:
  157. [source,js]
  158. --------------------------------------------------
  159. curl -XPUT localhost:9200/test/_settings -d '{
  160. "index.routing.allocation.include.group1" : "xxx"
  161. "index.routing.allocation.include.group2" : "yyy",
  162. "index.routing.allocation.exclude.group3" : "zzz",
  163. "index.routing.allocation.require.group4" : "aaa"
  164. }'
  165. --------------------------------------------------
  166. The provided settings can also be updated in real time using the update
  167. settings API, allowing to "move" indices (shards) around in realtime.
  168. Cluster wide filtering can also be defined, and be updated in real time
  169. using the cluster update settings API. This setting can come in handy
  170. for things like decommissioning nodes (even if the replica count is set
  171. to 0). Here is a sample of how to decommission a node based on `_ip`
  172. address:
  173. [source,js]
  174. --------------------------------------------------
  175. curl -XPUT localhost:9200/_cluster/settings -d '{
  176. "transient" : {
  177. "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
  178. }
  179. }'
  180. --------------------------------------------------