adding-removing-nodes.asciidoc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. [[modules-discovery-adding-removing-nodes]]
  2. === Adding and removing nodes
  3. As nodes are added or removed Elasticsearch maintains an optimal level of fault
  4. tolerance by automatically updating the cluster's _voting configuration_, which
  5. is the set of <<master-node,master-eligible nodes>> whose responses are counted
  6. when making decisions such as electing a new master or committing a new cluster
  7. state.
  8. It is recommended to have a small and fixed number of master-eligible nodes in a
  9. cluster, and to scale the cluster up and down by adding and removing
  10. master-ineligible nodes only. However there are situations in which it may be
  11. desirable to add or remove some master-eligible nodes to or from a cluster.
  12. [[modules-discovery-adding-nodes]]
  13. ==== Adding master-eligible nodes
  14. If you wish to add some nodes to your cluster, simply configure the new nodes
  15. to find the existing cluster and start them up. Elasticsearch adds the new nodes
  16. to the voting configuration if it is appropriate to do so.
  17. During master election or when joining an existing formed cluster, a node
  18. sends a join request to the master in order to be officially added to the
  19. cluster. You can use the `cluster.join.timeout` setting to configure how long a
  20. node waits after sending a request to join a cluster. Its default value is `30s`.
  21. See <<modules-discovery-settings>>.
  22. [[modules-discovery-removing-nodes]]
  23. ==== Removing master-eligible nodes
  24. When removing master-eligible nodes, it is important not to remove too many all
  25. at the same time. For instance, if there are currently seven master-eligible
  26. nodes and you wish to reduce this to three, it is not possible simply to stop
  27. four of the nodes at once: to do so would leave only three nodes remaining,
  28. which is less than half of the voting configuration, which means the cluster
  29. cannot take any further actions.
  30. More precisely, if you shut down half or more of the master-eligible nodes all
  31. at the same time then the cluster will normally become unavailable. If this
  32. happens then you can bring the cluster back online by starting the removed
  33. nodes again.
  34. As long as there are at least three master-eligible nodes in the cluster, as a
  35. general rule it is best to remove nodes one-at-a-time, allowing enough time for
  36. the cluster to <<modules-discovery-quorums,automatically adjust>> the voting
  37. configuration and adapt the fault tolerance level to the new set of nodes.
  38. If there are only two master-eligible nodes remaining then neither node can be
  39. safely removed since both are required to reliably make progress. To remove one
  40. of these nodes you must first inform {es} that it should not be part of the
  41. voting configuration, and that the voting power should instead be given to the
  42. other node. You can then take the excluded node offline without preventing the
  43. other node from making progress. A node which is added to a voting
  44. configuration exclusion list still works normally, but {es} tries to remove it
  45. from the voting configuration so its vote is no longer required. Importantly,
  46. {es} will never automatically move a node on the voting exclusions list back
  47. into the voting configuration. Once an excluded node has been successfully
  48. auto-reconfigured out of the voting configuration, it is safe to shut it down
  49. without affecting the cluster's master-level availability. A node can be added
  50. to the voting configuration exclusion list using the
  51. <<voting-config-exclusions>> API. For example:
  52. [source,console]
  53. --------------------------------------------------
  54. # Add node to voting configuration exclusions list and wait for the system
  55. # to auto-reconfigure the node out of the voting configuration up to the
  56. # default timeout of 30 seconds
  57. POST /_cluster/voting_config_exclusions?node_names=node_name
  58. # Add node to voting configuration exclusions list and wait for
  59. # auto-reconfiguration up to one minute
  60. POST /_cluster/voting_config_exclusions?node_names=node_name&timeout=1m
  61. --------------------------------------------------
  62. // TEST[skip:this would break the test cluster if executed]
  63. The nodes that should be added to the exclusions list are specified by name
  64. using the `?node_names` query parameter, or by their persistent node IDs using
  65. the `?node_ids` query parameter. If a call to the voting configuration
  66. exclusions API fails, you can safely retry it. Only a successful response
  67. guarantees that the node has actually been removed from the voting configuration
  68. and will not be reinstated. If the elected master node is excluded from the
  69. voting configuration then it will abdicate to another master-eligible node that
  70. is still in the voting configuration if such a node is available.
  71. Although the voting configuration exclusions API is most useful for down-scaling
  72. a two-node to a one-node cluster, it is also possible to use it to remove
  73. multiple master-eligible nodes all at the same time. Adding multiple nodes to
  74. the exclusions list has the system try to auto-reconfigure all of these nodes
  75. out of the voting configuration, allowing them to be safely shut down while
  76. keeping the cluster available. In the example described above, shrinking a
  77. seven-master-node cluster down to only have three master nodes, you could add
  78. four nodes to the exclusions list, wait for confirmation, and then shut them
  79. down simultaneously.
  80. NOTE: Voting exclusions are only required when removing at least half of the
  81. master-eligible nodes from a cluster in a short time period. They are not
  82. required when removing master-ineligible nodes, nor are they required when
  83. removing fewer than half of the master-eligible nodes.
  84. Adding an exclusion for a node creates an entry for that node in the voting
  85. configuration exclusions list, which has the system automatically try to
  86. reconfigure the voting configuration to remove that node and prevents it from
  87. returning to the voting configuration once it has removed. The current list of
  88. exclusions is stored in the cluster state and can be inspected as follows:
  89. [source,console]
  90. --------------------------------------------------
  91. GET /_cluster/state?filter_path=metadata.cluster_coordination.voting_config_exclusions
  92. --------------------------------------------------
  93. This list is limited in size by the `cluster.max_voting_config_exclusions`
  94. setting, which defaults to `10`. See <<modules-discovery-settings>>. Since
  95. voting configuration exclusions are persistent and limited in number, they must
  96. be cleaned up. Normally an exclusion is added when performing some maintenance
  97. on the cluster, and the exclusions should be cleaned up when the maintenance is
  98. complete. Clusters should have no voting configuration exclusions in normal
  99. operation.
  100. If a node is excluded from the voting configuration because it is to be shut
  101. down permanently, its exclusion can be removed after it is shut down and removed
  102. from the cluster. Exclusions can also be cleared if they were created in error
  103. or were only required temporarily by specifying `?wait_for_removal=false`.
  104. [source,console]
  105. --------------------------------------------------
  106. # Wait for all the nodes with voting configuration exclusions to be removed from
  107. # the cluster and then remove all the exclusions, allowing any node to return to
  108. # the voting configuration in the future.
  109. DELETE /_cluster/voting_config_exclusions
  110. # Immediately remove all the voting configuration exclusions, allowing any node
  111. # to return to the voting configuration in the future.
  112. DELETE /_cluster/voting_config_exclusions?wait_for_removal=false
  113. --------------------------------------------------