node.asciidoc 13 KB

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