adding-removing-nodes.asciidoc 6.7 KB

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