node.asciidoc 11 KB

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