bootstrapping.asciidoc 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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: nodes
  7. that have already joined a cluster store this information in their data folder
  8. for use in a <<restart-upgrade,full cluster restart>>, and freshly-started nodes
  9. that are joining a running cluster obtain this information from the cluster's
  10. elected master.
  11. The initial set of master-eligible nodes is defined in the
  12. <<initial_master_nodes,`cluster.initial_master_nodes` setting>>. This should be
  13. set to a list containing one of the following items for each master-eligible
  14. node:
  15. - The <<node-name,node name>> of the node.
  16. - The node's hostname if `node.name` is not set, because `node.name` defaults
  17. to the node's hostname. You must use either the fully-qualified hostname or
  18. the bare hostname <<modules-discovery-bootstrap-cluster-fqdns,depending on
  19. your system configuration>>.
  20. - The IP address of the node's <<modules-network-binding-publishing,transport
  21. publish address>>, if it is not possible to use the `node.name` of the node.
  22. This is normally the IP address to which
  23. <<common-network-settings,`network.host`>> resolves but
  24. <<advanced-network-settings,this can be overridden>>.
  25. - The IP address and port of the node's publish address, in the form `IP:PORT`,
  26. if it is not possible to use the `node.name` of the node and there are
  27. multiple nodes sharing a single IP address.
  28. When you start a master-eligible node, you can provide this setting on the
  29. command line or in the `elasticsearch.yml` file. After the cluster has formed,
  30. this setting is no longer required. It should not be set for master-ineligible
  31. nodes, master-eligible nodes joining an existing cluster, or cluster restarts.
  32. It is technically sufficient to set `cluster.initial_master_nodes` on a single
  33. master-eligible node in the cluster, and only to mention that single node in the
  34. setting's value, but this provides no fault tolerance before the cluster has
  35. fully formed. It is therefore better to bootstrap using at least three
  36. master-eligible nodes, each with a `cluster.initial_master_nodes` setting
  37. containing all three nodes.
  38. WARNING: You must set `cluster.initial_master_nodes` to the same list of nodes
  39. on each node on which it is set in order to be sure that only a single cluster
  40. forms during bootstrapping and therefore to avoid the risk of data loss.
  41. For a cluster with 3 master-eligible nodes (with <<node-name,node names>>
  42. `master-a`, `master-b` and `master-c`) the configuration will look as follows:
  43. [source,yaml]
  44. --------------------------------------------------
  45. cluster.initial_master_nodes:
  46. - master-a
  47. - master-b
  48. - master-c
  49. --------------------------------------------------
  50. Like all node settings, it is also possible to specify the initial set of master
  51. nodes on the command-line that is used to start Elasticsearch:
  52. [source,bash]
  53. --------------------------------------------------
  54. bin/elasticsearch -E cluster.initial_master_nodes=master-a,master-b,master-c
  55. --------------------------------------------------
  56. [[modules-discovery-bootstrap-cluster-fqdns]]
  57. .Node name formats must match
  58. ****
  59. The node names used in the
  60. `cluster.initial_master_nodes` list must exactly match the `node.name`
  61. properties of the nodes. By default the node name is set to the machine's
  62. hostname which may or may not be fully-qualified depending on your system
  63. configuration. If each node name is a fully-qualified domain name such as
  64. `master-a.example.com` then you must use fully-qualified domain names in the
  65. `cluster.initial_master_nodes` list too; conversely if your node names are bare
  66. hostnames (without the `.example.com` suffix) then you must use bare hostnames
  67. in the `cluster.initial_master_nodes` list. If you use a mix of fully-qualified
  68. and bare hostnames, or there is some other mismatch between `node.name` and
  69. `cluster.initial_master_nodes`, then the cluster will not form successfully and
  70. you will see log messages like the following.
  71. [source,text]
  72. --------------------------------------------------
  73. [master-a.example.com] master not discovered yet, this node has
  74. not previously joined a bootstrapped (v7+) cluster, and this
  75. node must discover master-eligible nodes [master-a, master-b] to
  76. bootstrap a cluster: have discovered [{master-b.example.com}{...
  77. --------------------------------------------------
  78. This message shows the node names `master-a.example.com` and
  79. `master-b.example.com` as well as the `cluster.initial_master_nodes` entries
  80. `master-a` and `master-b`, and it is clear from this message that they do not
  81. match exactly.
  82. ****
  83. [[bootstrap-cluster-name]]
  84. ==== Choosing a cluster name
  85. The <<cluster-name,`cluster.name`>> setting enables you to create multiple
  86. clusters which are separated from each other. Nodes verify that they agree on
  87. their cluster name when they first connect to each other, and Elasticsearch
  88. will only form a cluster from nodes that all have the same cluster name. The
  89. default value for the cluster name is `elasticsearch`, but it is recommended to
  90. change this to reflect the logical name of the cluster.
  91. [[bootstrap-auto-bootstrap]]
  92. ==== Auto-bootstrapping in development mode
  93. If the cluster is running with a completely default configuration then it will
  94. automatically bootstrap a cluster based on the nodes that could be discovered to
  95. be running on the same host within a short time after startup. This means that
  96. by default it is possible to start up several nodes on a single machine and have
  97. them automatically form a cluster which is very useful for development
  98. environments and experimentation. However, since nodes may not always
  99. successfully discover each other quickly enough this automatic bootstrapping
  100. cannot be relied upon and cannot be used in production deployments.
  101. If any of the following settings are configured then auto-bootstrapping will not
  102. take place, and you must configure `cluster.initial_master_nodes` as described
  103. in the <<modules-discovery-bootstrap-cluster,section on cluster bootstrapping>>:
  104. * `discovery.seed_providers`
  105. * `discovery.seed_hosts`
  106. * `cluster.initial_master_nodes`
  107. [[modules-discovery-bootstrap-cluster-joining]]
  108. .Forming a single cluster
  109. ****
  110. If you start an {es} node
  111. without configuring these settings then it will start up in development mode and
  112. auto-bootstrap itself into a new cluster. If you start some {es} nodes on
  113. different hosts then by default they will not discover each other and will form
  114. a different cluster on each host. {es} will not merge separate clusters together
  115. after they have formed, even if you subsequently try and configure all the nodes
  116. into a single cluster. This is because there is no way to merge these separate
  117. clusters together without a risk of data loss. You can tell that you have formed
  118. separate clusters by checking the cluster UUID reported by `GET /` on each node.
  119. If you intended to form a single cluster then you should start again:
  120. * Shut down all the nodes.
  121. * Completely wipe each node by deleting the contents of their
  122. <<data-path,data folders>>.
  123. * Configure `cluster.initial_master_nodes` as described above.
  124. * Restart all the nodes and verify that they have formed a single cluster.
  125. ****