adding-removing-nodes.asciidoc 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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,js]
  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_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_name?timeout=1m
  61. --------------------------------------------------
  62. // CONSOLE
  63. // TEST[skip:this would break the test cluster if executed]
  64. The node that should be added to the exclusions list is specified using
  65. <<cluster-nodes,node filters>> in place of `node_name` here. If a call to the
  66. voting configuration exclusions API fails, you can safely retry it. Only a
  67. successful response guarantees that the node has actually been removed from the
  68. voting configuration and will not be reinstated. If it's the active master that
  69. was removed from the voting configuration, then it will abdicate to another
  70. master-eligible node that's still in the voting configuration, if such a node
  71. is available.
  72. Although the voting configuration exclusions API is most useful for down-scaling
  73. a two-node to a one-node cluster, it is also possible to use it to remove
  74. multiple master-eligible nodes all at the same time. Adding multiple nodes to
  75. the exclusions list has the system try to auto-reconfigure all of these nodes
  76. out of the voting configuration, allowing them to be safely shut down while
  77. keeping the cluster available. In the example described above, shrinking a
  78. seven-master-node cluster down to only have three master nodes, you could add
  79. four nodes to the exclusions list, wait for confirmation, and then shut them
  80. down simultaneously.
  81. NOTE: Voting exclusions are only required when removing at least half of the
  82. master-eligible nodes from a cluster in a short time period. They are not
  83. required when removing master-ineligible nodes, nor are they required when
  84. removing fewer than half of the master-eligible nodes.
  85. Adding an exclusion for a node creates an entry for that node in the voting
  86. configuration exclusions list, which has the system automatically try to
  87. reconfigure the voting configuration to remove that node and prevents it from
  88. returning to the voting configuration once it has removed. The current list of
  89. exclusions is stored in the cluster state and can be inspected as follows:
  90. [source,js]
  91. --------------------------------------------------
  92. GET /_cluster/state?filter_path=metadata.cluster_coordination.voting_config_exclusions
  93. --------------------------------------------------
  94. // CONSOLE
  95. This list is limited in size by the `cluster.max_voting_config_exclusions`
  96. setting, which defaults to `10`. See <<modules-discovery-settings>>. Since
  97. voting configuration exclusions are persistent and limited in number, they must
  98. be cleaned up. Normally an exclusion is added when performing some maintenance
  99. on the cluster, and the exclusions should be cleaned up when the maintenance is
  100. complete. Clusters should have no voting configuration exclusions in normal
  101. operation.
  102. If a node is excluded from the voting configuration because it is to be shut
  103. down permanently, its exclusion can be removed after it is shut down and removed
  104. from the cluster. Exclusions can also be cleared if they were created in error
  105. or were only required temporarily:
  106. [source,js]
  107. --------------------------------------------------
  108. # Wait for all the nodes with voting configuration exclusions to be removed from
  109. # the cluster and then remove all the exclusions, allowing any node to return to
  110. # the voting configuration in the future.
  111. DELETE /_cluster/voting_config_exclusions
  112. # Immediately remove all the voting configuration exclusions, allowing any node
  113. # to return to the voting configuration in the future.
  114. DELETE /_cluster/voting_config_exclusions?wait_for_removal=false
  115. --------------------------------------------------
  116. // CONSOLE