bootstrapping.asciidoc 6.8 KB

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