adding-removing-nodes.asciidoc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. As long as there are at least three master-eligible nodes in the cluster, as a
  31. general rule it is best to remove nodes one-at-a-time, allowing enough time for
  32. the cluster to <<modules-discovery-quorums,automatically adjust>> the voting
  33. configuration and adapt the fault tolerance level to the new set of nodes.
  34. If there are only two master-eligible nodes remaining then neither node can be
  35. safely removed since both are required to reliably make progress. You must first
  36. inform Elasticsearch that one of the nodes should not be part of the voting
  37. configuration, and that the voting power should instead be given to other nodes.
  38. You can then take the excluded node offline without preventing the other node
  39. from making progress. A node which is added to a voting configuration exclusion
  40. list still works normally, but Elasticsearch tries to remove it from the voting
  41. configuration so its vote is no longer required. Importantly, Elasticsearch
  42. will never automatically move a node on the voting exclusions list back into the
  43. voting configuration. Once an excluded node has been successfully
  44. auto-reconfigured out of the voting configuration, it is safe to shut it down
  45. without affecting the cluster's master-level availability. A node can be added
  46. to the voting configuration exclusion list using the <<voting-config-exclusions>> API. For example:
  47. [source,js]
  48. --------------------------------------------------
  49. # Add node to voting configuration exclusions list and wait for the system to
  50. # auto-reconfigure the node out of the voting configuration up to the default
  51. # timeout of 30 seconds
  52. POST /_cluster/voting_config_exclusions/node_name
  53. # Add node to voting configuration exclusions list and wait for
  54. # auto-reconfiguration up to one minute
  55. POST /_cluster/voting_config_exclusions/node_name?timeout=1m
  56. --------------------------------------------------
  57. // CONSOLE
  58. // TEST[skip:this would break the test cluster if executed]
  59. The node that should be added to the exclusions list is specified using
  60. <<cluster-nodes,node filters>> in place of `node_name` here. If a call to the
  61. voting configuration exclusions API fails, you can safely retry it. Only a
  62. successful response guarantees that the node has actually been removed from the
  63. voting configuration and will not be reinstated.
  64. Although the voting configuration exclusions API is most useful for down-scaling
  65. a two-node to a one-node cluster, it is also possible to use it to remove
  66. multiple master-eligible nodes all at the same time. Adding multiple nodes to
  67. the exclusions list has the system try to auto-reconfigure all of these nodes
  68. out of the voting configuration, allowing them to be safely shut down while
  69. keeping the cluster available. In the example described above, shrinking a
  70. seven-master-node cluster down to only have three master nodes, you could add
  71. four nodes to the exclusions list, wait for confirmation, and then shut them
  72. down simultaneously.
  73. NOTE: Voting exclusions are only required when removing at least half of the
  74. master-eligible nodes from a cluster in a short time period. They are not
  75. required when removing master-ineligible nodes, nor are they required when
  76. removing fewer than half of the master-eligible nodes.
  77. Adding an exclusion for a node creates an entry for that node in the voting
  78. configuration exclusions list, which has the system automatically try to
  79. reconfigure the voting configuration to remove that node and prevents it from
  80. returning to the voting configuration once it has removed. The current list of
  81. exclusions is stored in the cluster state and can be inspected as follows:
  82. [source,js]
  83. --------------------------------------------------
  84. GET /_cluster/state?filter_path=metadata.cluster_coordination.voting_config_exclusions
  85. --------------------------------------------------
  86. // CONSOLE
  87. This list is limited in size by the `cluster.max_voting_config_exclusions`
  88. setting, which defaults to `10`. See <<modules-discovery-settings>>. Since
  89. voting configuration exclusions are persistent and limited in number, they must
  90. be cleaned up. Normally an exclusion is added when performing some maintenance
  91. on the cluster, and the exclusions should be cleaned up when the maintenance is
  92. complete. Clusters should have no voting configuration exclusions in normal
  93. operation.
  94. If a node is excluded from the voting configuration because it is to be shut
  95. down permanently, its exclusion can be removed after it is shut down and removed
  96. from the cluster. Exclusions can also be cleared if they were created in error
  97. or were only required temporarily:
  98. [source,js]
  99. --------------------------------------------------
  100. # Wait for all the nodes with voting configuration exclusions to be removed from
  101. # the cluster and then remove all the exclusions, allowing any node to return to
  102. # the voting configuration in the future.
  103. DELETE /_cluster/voting_config_exclusions
  104. # Immediately remove all the voting configuration exclusions, allowing any node
  105. # to return to the voting configuration in the future.
  106. DELETE /_cluster/voting_config_exclusions?wait_for_removal=false
  107. --------------------------------------------------
  108. // CONSOLE