cluster.asciidoc 8.9 KB

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