node.asciidoc 10 KB

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