node.asciidoc 13 KB

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