bootstrapping.asciidoc 7.3 KB

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