important-settings.asciidoc 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. [[important-settings]]
  2. == Important Elasticsearch configuration
  3. While Elasticsearch requires very little configuration, there are a number of
  4. settings which need to be configured manually and should definitely be
  5. configured before going into production.
  6. * <<path-settings,`path.data` and `path.logs`>>
  7. * <<cluster.name,`cluster.name`>>
  8. * <<node.name,`node.name`>>
  9. * <<bootstrap.memory_lock,`bootstrap.memory_lock`>>
  10. * <<network.host,`network.host`>>
  11. * <<unicast.hosts,`discovery.zen.ping.unicast.hosts`>>
  12. * <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>
  13. [float]
  14. [[path-settings]]
  15. === `path.data` and `path.logs`
  16. If you are using the `.zip` or `.tar.gz` archives, the `data` and `logs`
  17. directories are sub-folders of `$ES_HOME`. If these important folders are
  18. left in their default locations, there is a high risk of them being deleted
  19. while upgrading Elasticsearch to a new version.
  20. In production use, you will almost certainly want to change the locations of
  21. the data and log folder:
  22. [source,yaml]
  23. --------------------------------------------------
  24. path:
  25. logs: /var/log/elasticsearch
  26. data: /var/data/elasticsearch
  27. --------------------------------------------------
  28. The RPM and Debian distributions already use custom paths for `data` and
  29. `logs`.
  30. The `path.data` settings can be set to multiple paths, in which case all paths
  31. will be used to store data (although the files belonging to a single shard
  32. will all be stored on the same data path):
  33. [source,yaml]
  34. --------------------------------------------------
  35. path:
  36. data:
  37. - /mnt/elasticsearch_1
  38. - /mnt/elasticsearch_2
  39. - /mnt/elasticsearch_3
  40. --------------------------------------------------
  41. [float]
  42. [[cluster.name]]
  43. === `cluster.name`
  44. A node can only join a cluster when it shares its `cluster.name` with all the
  45. other nodes in the cluster. The default name is `elasticsearch`, but you
  46. should change it to an appropriate name which describes the purpose of the
  47. cluster.
  48. [source,yaml]
  49. --------------------------------------------------
  50. cluster.name: logging-prod
  51. --------------------------------------------------
  52. Make sure that you don't reuse the same cluster names in different
  53. environments, otherwise you might end up with nodes joining the wrong cluster.
  54. [float]
  55. [[node.name]]
  56. === `node.name`
  57. By default, Elasticsearch will take the 7 first character of the randomly generated uuid used as the node id.
  58. Note that the node id is persisted and does not change when a node restarts and therefore the default node name
  59. will also not change.
  60. It is worth configuring a more meaningful name which will also have the
  61. advantage of persisting after restarting the node:
  62. [source,yaml]
  63. --------------------------------------------------
  64. node.name: prod-data-2
  65. --------------------------------------------------
  66. The `node.name` can also be set to the server's HOSTNAME as follows:
  67. [source,yaml]
  68. --------------------------------------------------
  69. node.name: ${HOSTNAME}
  70. --------------------------------------------------
  71. [float]
  72. [[bootstrap.memory_lock]]
  73. === `bootstrap.memory_lock`
  74. It is vitally important to the health of your node that none of the JVM is
  75. ever swapped out to disk. One way of achieving that is set the
  76. `bootstrap.memory_lock` setting to `true`.
  77. For this setting to have effect, other system settings need to be configured
  78. first. See <<mlockall>> for more details about how to set up memory locking
  79. correctly.
  80. [float]
  81. [[network.host]]
  82. === `network.host`
  83. By default, Elasticsearch binds to loopback addresses only -- e.g. `127.0.0.1`
  84. and `[::1]`. This is sufficient to run a single development node on a server.
  85. TIP: In fact, more than one node can be started from the same `$ES_HOME` location
  86. on a single node. This can be useful for testing Elasticsearch's ability to
  87. form clusters, but it is not a configuration recommended for production.
  88. In order to communicate and to form a cluster with nodes on other servers,
  89. your node will need to bind to a non-loopback address. While there are many
  90. <<modules-network,network settings>>, usually all you need to configure is
  91. `network.host`:
  92. [source,yaml]
  93. --------------------------------------------------
  94. network.host: 192.168.1.10
  95. --------------------------------------------------
  96. The `network.host` setting also understands some special values such as
  97. `_local_`, `_site_`, `_global_` and modifiers like `:ip4` and `:ip6`, details
  98. of which can be found in <<network-interface-values>>.
  99. IMPORTANT: As soon you provide a custom setting for `network.host`,
  100. Elasticsearch assumes that you are moving from development mode to production
  101. mode, and upgrades a number of system startup checks from warnings to
  102. exceptions. See <<dev-vs-prod>> for more information.
  103. [float]
  104. [[unicast.hosts]]
  105. === `discovery.zen.ping.unicast.hosts`
  106. Out of the box, without any network configuration, Elasticsearch will bind to
  107. the available loopback addresses and will scan ports 9300 to 9305 to try to
  108. connect to other nodes running on the same server. This provides an auto-
  109. clustering experience without having to do any configuration.
  110. When the moment comes to form a cluster with nodes on other servers, you have
  111. to provide a seed list of other nodes in the cluster that are likely to be
  112. live and contactable. This can be specified as follows:
  113. [source,yaml]
  114. --------------------------------------------------
  115. discovery.zen.ping.unicast.hosts:
  116. - 192.168.1.10:9300
  117. - 192.168.1.11 <1>
  118. - seeds.mydomain.com <2>
  119. --------------------------------------------------
  120. <1> The port will default to 9300 if not specified.
  121. <2> A hostname that resolves to multiple IP addresses will try all resolved addresses.
  122. [float]
  123. [[minimum_master_nodes]]
  124. === `discovery.zen.minimum_master_nodes`
  125. To prevent data loss, it is vital to configure the
  126. `discovery.zen.minimum_master_nodes setting` so that each master-eligible node
  127. knows the _minimum number of master-eligible nodes_ that must be visible in
  128. order to form a cluster.
  129. Without this setting, a cluster that suffers a network failure is at risk of
  130. having the cluster split into two independent clusters -- a split brain --
  131. which will lead to data loss. A more detailed explanation is provided
  132. in <<split-brain>>.
  133. To avoid a split brain, this setting should be set to a _quorum_ of master-
  134. eligible nodes:
  135. (master_eligible_nodes / 2) + 1
  136. In other words, if there are three master-eligible nodes, then minimum master
  137. nodes should be set to `(3 / 2) + 1` or `2`:
  138. [source,yaml]
  139. --------------------------------------------------
  140. discovery.zen.minimum_master_nodes: 2
  141. --------------------------------------------------
  142. IMPORTANT: If `discovery.zen.minimum_master_nodes` is not set when
  143. Elasticsearch is running in <<dev-vs-prod,production mode>>, an exception will
  144. be thrown which will prevent the node from starting.