bootstrapping.asciidoc 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. [[modules-discovery-bootstrap-cluster]]
  2. === Bootstrapping a cluster
  3. Starting an Elasticsearch cluster for the very first time requires the initial
  4. set of <<master-node,master-eligible nodes>> to be explicitly defined on one or
  5. more of the master-eligible nodes in the cluster. This is known as _cluster
  6. bootstrapping_. This is only required the first time a cluster starts up.
  7. Freshly-started nodes that are joining a running cluster obtain this
  8. information from the cluster's elected master.
  9. The initial set of master-eligible nodes is defined in the
  10. <<initial_master_nodes,`cluster.initial_master_nodes` setting>>. This should be
  11. set to a list containing one of the following items for each master-eligible
  12. node:
  13. - The <<node-name,node name>> of the node.
  14. - The node's hostname if `node.name` is not set, because `node.name` defaults
  15. to the node's hostname. You must use either the fully-qualified hostname or
  16. the bare hostname <<modules-discovery-bootstrap-cluster-fqdns,depending on
  17. your system configuration>>.
  18. - The IP address of the node's <<modules-network-binding-publishing,transport
  19. publish address>>, if it is not possible to use the `node.name` of the node.
  20. This is normally the IP address to which
  21. <<common-network-settings,`network.host`>> resolves but
  22. <<advanced-network-settings,this can be overridden>>.
  23. - The IP address and port of the node's publish address, in the form `IP:PORT`,
  24. if it is not possible to use the `node.name` of the node and there are
  25. multiple nodes sharing a single IP address.
  26. Do not set `cluster.initial_master_nodes` on master-ineligible nodes.
  27. [IMPORTANT]
  28. ====
  29. After the cluster has formed, remove the `cluster.initial_master_nodes` setting
  30. from each node's configuration and never set it again for this cluster. Do not
  31. configure this setting on nodes joining an existing cluster. Do not configure
  32. this setting on nodes which are restarting. Do not configure this setting when
  33. performing a full-cluster restart.
  34. If you leave `cluster.initial_master_nodes` in place once the cluster has formed
  35. then there is a risk that a future misconfiguration may result in bootstrapping
  36. a new cluster alongside your existing cluster. It may not be possible to recover
  37. from this situation without losing data.
  38. ====
  39. The simplest way to create a new cluster is for you to select one of your
  40. master-eligible nodes that will bootstrap itself into a single-node cluster,
  41. which all the other nodes will then join. This simple approach is not resilient
  42. to failures until the other master-eligible nodes have joined the cluster. For
  43. example, if you have a master-eligible node with <<node-name,node name>>
  44. `master-a` then configure it as follows (omitting
  45. `cluster.initial_master_nodes` from the configuration of all other nodes):
  46. [source,yaml]
  47. --------------------------------------------------
  48. cluster.initial_master_nodes: master-a
  49. --------------------------------------------------
  50. For fault-tolerant cluster bootstrapping, use all the master-eligible nodes.
  51. For instance, if your cluster has 3 master-eligible nodes with <<node-name,node
  52. names>> `master-a`, `master-b` and `master-c` then configure them all as
  53. follows:
  54. [source,yaml]
  55. --------------------------------------------------
  56. cluster.initial_master_nodes:
  57. - master-a
  58. - master-b
  59. - master-c
  60. --------------------------------------------------
  61. IMPORTANT: You must set `cluster.initial_master_nodes` to the same list of
  62. nodes on each node on which it is set in order to be sure that only a single
  63. cluster forms during bootstrapping. If `cluster.initial_master_nodes` varies
  64. across the nodes on which it is set then you may bootstrap multiple clusters.
  65. It is usually not possible to recover from this situation without losing data.
  66. [[modules-discovery-bootstrap-cluster-fqdns]]
  67. .Node name formats must match
  68. ****
  69. The node names used in the
  70. `cluster.initial_master_nodes` list must exactly match the `node.name`
  71. properties of the nodes. By default the node name is set to the machine's
  72. hostname which may or may not be fully-qualified depending on your system
  73. configuration. If each node name is a fully-qualified domain name such as
  74. `master-a.example.com` then you must use fully-qualified domain names in the
  75. `cluster.initial_master_nodes` list too; conversely if your node names are bare
  76. hostnames (without the `.example.com` suffix) then you must use bare hostnames
  77. in the `cluster.initial_master_nodes` list. If you use a mix of fully-qualified
  78. and bare hostnames, or there is some other mismatch between `node.name` and
  79. `cluster.initial_master_nodes`, then the cluster will not form successfully and
  80. you will see log messages like the following.
  81. [source,text]
  82. --------------------------------------------------
  83. [master-a.example.com] master not discovered yet, this node has
  84. not previously joined a bootstrapped (v7+) cluster, and this
  85. node must discover master-eligible nodes [master-a, master-b] to
  86. bootstrap a cluster: have discovered [{master-b.example.com}{...
  87. --------------------------------------------------
  88. This message shows the node names `master-a.example.com` and
  89. `master-b.example.com` as well as the `cluster.initial_master_nodes` entries
  90. `master-a` and `master-b`, and it is clear from this message that they do not
  91. match exactly.
  92. ****
  93. [[bootstrap-cluster-name]]
  94. ==== Choosing a cluster name
  95. The <<cluster-name,`cluster.name`>> setting enables you to create multiple
  96. clusters which are separated from each other. Nodes verify that they agree on
  97. their cluster name when they first connect to each other, and Elasticsearch
  98. will only form a cluster from nodes that all have the same cluster name. The
  99. default value for the cluster name is `elasticsearch`, but it is recommended to
  100. change this to reflect the logical name of the cluster.
  101. [[bootstrap-auto-bootstrap]]
  102. ==== Auto-bootstrapping in development mode
  103. By default each node will automatically bootstrap itself into a single-node
  104. cluster the first time it starts. If any of the following settings are
  105. configured then auto-bootstrapping will not take place:
  106. * `discovery.seed_providers`
  107. * `discovery.seed_hosts`
  108. * `cluster.initial_master_nodes`
  109. To add a new node into an existing cluster, configure `discovery.seed_hosts` or
  110. other relevant discovery settings so that the new node can discover the
  111. existing master-eligible nodes in the cluster. To bootstrap a new multi-node
  112. cluster, configure `cluster.initial_master_nodes` as described in the
  113. <<modules-discovery-bootstrap-cluster,section on cluster bootstrapping>> as
  114. well as `discovery.seed_hosts` or other relevant discovery settings.
  115. [[modules-discovery-bootstrap-cluster-joining]]
  116. .Forming a single cluster
  117. ****
  118. Once an {es} node has joined an existing cluster, or bootstrapped a new
  119. cluster, it will not join a different cluster. {es} will not merge separate
  120. clusters together after they have formed, even if you subsequently try and
  121. configure all the nodes into a single cluster. This is because there is no way
  122. to merge these separate clusters together without a risk of data loss. You can
  123. tell that you have formed separate clusters by checking the cluster UUID
  124. reported by `GET /` on each node.
  125. If you intended to add a node into an existing cluster but instead bootstrapped
  126. a separate single-node cluster then you must start again:
  127. . Shut down the node.
  128. . Completely wipe the node by deleting the contents of its <<data-path,data
  129. folder>>.
  130. . Configure `discovery.seed_hosts` or `discovery.seed_providers` and other
  131. relevant discovery settings. Ensure `cluster.initial_master_nodes` is not set
  132. on any node.
  133. . Restart the node and verify that it joins the existing cluster rather than
  134. forming its own one-node cluster.
  135. If you intended to form a new multi-node cluster but instead bootstrapped a
  136. collection of single-node clusters then you must start again:
  137. . Shut down all the nodes.
  138. . Completely wipe each node by deleting the contents of their <<data-path,data
  139. folders>>.
  140. . Configure `cluster.initial_master_nodes` as described above.
  141. . Configure `discovery.seed_hosts` or `discovery.seed_providers` and other
  142. relevant discovery settings.
  143. . Restart all the nodes and verify that they have formed a single cluster.
  144. . Remove `cluster.initial_master_nodes` from every node's configuration.
  145. ****