node.asciidoc 12 KB

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