node.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. [[modules-node]]
  2. == Node
  3. Any time that you start an instance of Elasticsearch, you are starting a
  4. _node_. A collection of connected nodes is called a
  5. <<modules-cluster,cluster>>. If you are running a single node of Elasticsearch,
  6. then you have a cluster of one node.
  7. Every node in the cluster can handle <<modules-http,HTTP>> and
  8. <<modules-transport,Transport>> traffic by default. The transport layer
  9. is used exclusively for communication between nodes and between nodes and the
  10. {javaclient}/transport-client.html[Java `TransportClient`]; the HTTP layer is
  11. used only by external REST clients.
  12. All nodes know about all the other nodes in the cluster and can forward client
  13. requests to the appropriate node. Besides that, each node serves one or more
  14. purpose:
  15. <<master-node,Master-eligible node>>::
  16. A node that has `node.master` set to `true` (default), which makes it eligible
  17. to be <<modules-discovery-zen,elected as the _master_ node>>, which controls
  18. the cluster.
  19. <<data-node,Data node>>::
  20. A node that has `node.data` set to `true` (default). Data nodes hold data and
  21. perform data related operations such as CRUD, search, and aggregations.
  22. <<ingest,Ingest node>>::
  23. A node that has `node.ingest` set to `true` (default). Ingest nodes can be
  24. used to pre-process documents before the actual indexing takes place.
  25. <<modules-tribe,Tribe node>>::
  26. A tribe node, configured via the `tribe.*` settings, is a special type of
  27. coordinating only node that can connect to multiple clusters and perform
  28. search and other operations across all connected clusters.
  29. By default a node is a master-eligible node and a data node, plus it can
  30. pre-process documents through ingest pipelines. This is very convenient for
  31. small clusters but, as the cluster grows, it becomes important to consider
  32. separating dedicated master-eligible nodes from dedicated data nodes.
  33. [NOTE]
  34. [[coordinating-node]]
  35. .Coordinating node
  36. ===============================================
  37. Requests like search requests or bulk-indexing requests may involve data held
  38. on different data nodes. A search request, for example, is executed in two
  39. phases which are coordinated by the node which receives the client request --
  40. the _coordinating node_.
  41. In the _scatter_ phase, the coordinating node forwards the request to the data
  42. nodes which hold the data. Each data node executes the request locally and
  43. returns its results to the coordinating node. In the _gather_ phase, the
  44. coordinating node reduces each data node's results into a single global
  45. resultset.
  46. Every node is implicitly a coordinating node. This means that a node that has
  47. all three `node.master`, `node.data` and `node.ingest` set to `false` will
  48. only act as a coordinating node, which cannot be disabled. As a result, such
  49. a node needs to have enough memory and CPU in order to deal with the gather
  50. phase.
  51. ===============================================
  52. [float]
  53. [[master-node]]
  54. === Master Eligible Node
  55. The master node is responsible for lightweight cluster-wide actions such as
  56. creating or deleting an index, tracking which nodes are part of the cluster,
  57. and deciding which shards to allocate to which nodes. It is important for
  58. cluster health to have a stable master node.
  59. Any master-eligible node (all nodes by default) may be elected to become the
  60. master node by the <<modules-discovery-zen,master election process>>.
  61. Indexing and searching your data is CPU-, memory-, and I/O-intensive work
  62. which can put pressure on a node's resources. To ensure that your master
  63. node is stable and not under pressure, it is a good idea in a bigger
  64. cluster to split the roles between dedicated master-eligible nodes and
  65. dedicated data nodes.
  66. While master nodes can also behave as <<coordinating-node,coordinating nodes>>
  67. and route search and indexing requests from clients to data nodes, it is
  68. better _not_ to use dedicated master nodes for this purpose. It is important
  69. for the stability of the cluster that master-eligible nodes do as little work
  70. as possible.
  71. To create a standalone master-eligible node, set:
  72. [source,yaml]
  73. -------------------
  74. node.master: true <1>
  75. node.data: false <2>
  76. node.ingest: false <3>
  77. -------------------
  78. <1> The `node.master` role is enabled by default.
  79. <2> Disable the `node.data` role (enabled by default).
  80. <3> Disable the `node.ingest` role (enabled by default).
  81. [float]
  82. [[split-brain]]
  83. ==== Avoiding split brain with `minimum_master_nodes`
  84. To prevent data loss, it is vital to configure the
  85. `discovery.zen.minimum_master_nodes` setting (which defaults to `1`) so that
  86. each master-eligible node knows the _minimum number of master-eligible nodes_
  87. that must be visible in order to form a cluster.
  88. To explain, imagine that you have a cluster consisting of two master-eligible
  89. nodes. A network failure breaks communication between these two nodes. Each
  90. node sees one master-eligible node... itself. With `minimum_master_nodes` set
  91. to the default of `1`, this is sufficient to form a cluster. Each node elects
  92. itself as the new master (thinking that the other master-eligible node has
  93. died) and the result is two clusters, or a _split brain_. These two nodes
  94. will never rejoin until one node is restarted. Any data that has been written
  95. to the restarted node will be lost.
  96. Now imagine that you have a cluster with three master-eligible nodes, and
  97. `minimum_master_nodes` set to `2`. If a network split separates one node from
  98. the other two nodes, the side with one node cannot see enough master-eligible
  99. nodes and will realise that it cannot elect itself as master. The side with
  100. two nodes will elect a new master (if needed) and continue functioning
  101. correctly. As soon as the network split is resolved, the single node will
  102. rejoin the cluster and start serving requests again.
  103. This setting should be set to a _quorum_ of master-eligible nodes:
  104. (master_eligible_nodes / 2) + 1
  105. In other words, if there are three master-eligible nodes, then minimum master
  106. nodes should be set to `(3 / 2) + 1` or `2`:
  107. [source,yaml]
  108. ----------------------------
  109. discovery.zen.minimum_master_nodes: 2 <1>
  110. ----------------------------
  111. <1> Defaults to `1`.
  112. This setting can also be changed dynamically on a live cluster with the
  113. <<cluster-update-settings,cluster update settings API>>:
  114. [source,js]
  115. ----------------------------
  116. PUT _cluster/settings
  117. {
  118. "transient": {
  119. "discovery.zen.minimum_master_nodes": 2
  120. }
  121. }
  122. ----------------------------
  123. // AUTOSENSE
  124. TIP: An advantage of splitting the master and data roles between dedicated
  125. nodes is that you can have just three master-eligible nodes and set
  126. `minimum_master_nodes` to `2`. You never have to change this setting, no
  127. matter how many dedicated data nodes you add to the cluster.
  128. [float]
  129. [[data-node]]
  130. === Data Node
  131. Data nodes hold the shards that contain the documents you have indexed. Data
  132. nodes handle data related operations like CRUD, search, and aggregations.
  133. These operations are I/O-, memory-, and CPU-intensive. It is important to
  134. monitor these resources and to add more data nodes if they are overloaded.
  135. The main benefit of having dedicated data nodes is the separation of the
  136. master and data roles.
  137. To create a dedicated data node, set:
  138. [source,yaml]
  139. -------------------
  140. node.master: false <1>
  141. node.data: true <2>
  142. node.ingest: false <3>
  143. -------------------
  144. <1> Disable the `node.master` role (enabled by default).
  145. <2> The `node.data` role is enabled by default.
  146. <3> Disable the `node.ingest` role (enabled by default).
  147. [float]
  148. [[node-ingest-node]]
  149. === Ingest Node
  150. Ingest nodes can execute pre-processing pipelines, composed of one or more
  151. ingest processors. Depending on the type of operations performed by the ingest
  152. processors and the required resources, it may make sense to have dedicated
  153. ingest nodes, that will only perform this specific task.
  154. To create a dedicated ingest node, set:
  155. [source,yaml]
  156. -------------------
  157. node.master: false <1>
  158. node.data: false <2>
  159. node.ingest: true <3>
  160. -------------------
  161. <1> Disable the `node.master` role (enabled by default).
  162. <2> Disable the `node.data` role (enabled by default).
  163. <3> The `node.ingest` role is enabled by default.
  164. [float]
  165. [[coordinating-only-node]]
  166. === Coordinating only node
  167. If you take away the ability to be able to handle master duties, to hold data,
  168. and pre-process documents, then you are left with a _coordinating_ node that
  169. can only route requests, handle the search reduce phase, and distribute bulk
  170. indexing. Essentially, coordinating only nodes behave as smart load balancers.
  171. Coordinating only nodes can benefit large clusters by offloading the
  172. coordinating node role from data and master-eligible nodes. They join the
  173. cluster and receive the full <<cluster-state,cluster state>>, like every other
  174. node, and they use the cluster state to route requests directly to the
  175. appropriate place(s).
  176. WARNING: Adding too many coordinating only nodes to a cluster can increase the
  177. burden on the entire cluster because the elected master node must await
  178. acknowledgement of cluster state updates from every node! The benefit of
  179. coordinating only nodes should not be overstated -- data nodes can happily
  180. serve the same purpose.
  181. To create a coordinating only node, set:
  182. [source,yaml]
  183. -------------------
  184. node.master: false <1>
  185. node.data: false <2>
  186. node.ingest: false <3>
  187. -------------------
  188. <1> Disable the `node.master` role (enabled by default).
  189. <2> Disable the `node.data` role (enabled by default).
  190. <3> Disable the `node.ingest` role (enabled by default).
  191. [float]
  192. == Node data path settings
  193. [float]
  194. [[data-path]]
  195. === `path.data`
  196. Every data and master-eligible node requires access to a data directory where
  197. shards and index and cluster metadata will be stored. The `path.data` defaults
  198. to `$ES_HOME/data` but can be configured in the `elasticsearch.yml` config
  199. file an absolute path or a path relative to `$ES_HOME` as follows:
  200. [source,yaml]
  201. -----------------------
  202. path.data: /var/elasticsearch/data
  203. -----------------------
  204. Like all node settings, it can also be specified on the command line as:
  205. [source,sh]
  206. -----------------------
  207. ./bin/elasticsearch --path.data /var/elasticsearch/data
  208. -----------------------
  209. TIP: When using the `.zip` or `.tar.gz` distributions, the `path.data` setting
  210. should be configured to locate the data directory outside the Elasticsearch
  211. home directory, so that the home directory can be deleted without deleting
  212. your data! The RPM and Debian distributions do this for you already.
  213. [float]
  214. [[max-local-storage-nodes]]
  215. === `node.max_local_storage_nodes`
  216. The <<data-path,data path>> can be shared by multiple nodes, even by nodes
  217. from different clusters. This is very useful for testing failover and
  218. different configurations on your development machine. In production, however,
  219. it is recommended to run only one node of Elasticsearch per server.
  220. To prevent more than one node from sharing the same data path, add this
  221. setting to the `elasticsearch.yml` config file:
  222. [source,yaml]
  223. ------------------------------
  224. node.max_local_storage_nodes: 1
  225. ------------------------------
  226. WARNING: Never run different node types (i.e. master, data) from the
  227. same data directory. This can lead to unexpected data loss.
  228. [float]
  229. == Other node settings
  230. More node settings can be found in <<modules,Modules>>. Of particular note are
  231. the <<cluster-name,`cluster.name`>>, the <<node-name,`node.name`>> and the
  232. <<modules-network,network settings>>.