network.asciidoc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. [[modules-network]]
  2. === Networking
  3. Each {es} node has two different network interfaces. Clients send requests to
  4. {es}'s REST APIs using its <<http-settings,HTTP interface>>, but nodes
  5. communicate with other nodes using the <<transport-settings,transport
  6. interface>>. The transport interface is also used for communication with
  7. <<remote-clusters,remote clusters>>. The transport interface uses a custom
  8. binary protocol sent over <<long-lived-connections,long-lived>> TCP channels.
  9. Both interfaces can be configured to use <<secure-cluster,TLS for security>>.
  10. You can configure both of these interfaces at the same time using the
  11. `network.*` settings. If you have a more complicated network, you might need to
  12. configure the interfaces independently using the `http.*` and `transport.*`
  13. settings. Where possible, use the `network.*` settings that apply to both
  14. interfaces to simplify your configuration and reduce duplication.
  15. By default {es} binds only to `localhost` which means it cannot be accessed
  16. remotely. This configuration is sufficient for a local development cluster made
  17. of one or more nodes all running on the same host. To form a cluster across
  18. multiple hosts, or which is accessible to remote clients, you must adjust some
  19. <<common-network-settings,network settings>> such as `network.host`.
  20. [WARNING]
  21. .Be careful with the network configuration!
  22. =============================
  23. Never expose an unprotected node to the public internet. If you do, you are
  24. permitting anyone in the world to download, modify, or delete any of the data
  25. in your cluster.
  26. =============================
  27. Configuring {es} to bind to a non-local address will <<dev-vs-prod,convert some
  28. warnings into fatal exceptions>>. If a node refuses to start after configuring
  29. its network settings then you must address the logged exceptions before
  30. proceeding.
  31. [[common-network-settings]]
  32. ==== Commonly used network settings
  33. Most users will need to configure only the following network settings.
  34. `network.host`::
  35. (<<static-cluster-setting,Static>>, string)
  36. Sets the address of this node for both HTTP and transport traffic. The node
  37. will bind to this address and will also use it as its publish address. Accepts
  38. an IP address, a hostname, or a <<network-interface-values,special value>>.
  39. +
  40. Defaults to `_local_`. However, note that <<configuring-stack-security,security
  41. auto-configuration>> will add `http.host: 0.0.0.0` to your `elasticsearch.yml`
  42. configuration file, which overrides this default for HTTP traffic.
  43. `http.port`::
  44. (<<static-cluster-setting,Static>>, integer)
  45. The port to bind for HTTP client communication. Accepts a single value or a
  46. range. If a range is specified, the node will bind to the first available port
  47. in the range.
  48. +
  49. Defaults to `9200-9300`.
  50. `transport.port`::
  51. (<<static-cluster-setting,Static>>, integer)
  52. The port to bind for communication between nodes. Accepts a single value or a
  53. range. If a range is specified, the node will bind to the first available port
  54. in the range. Set this setting to a single port, not a range, on every
  55. master-eligible node.
  56. +
  57. Defaults to `9300-9400`.
  58. [[remote_cluster.port]]
  59. `remote_cluster.port`::
  60. (<<static-cluster-setting,Static>>, integer)
  61. The port to bind for remote cluster client communication. Accepts a single value.
  62. +
  63. Defaults to `9443`.
  64. [[network-interface-values]]
  65. ==== Special values for network addresses
  66. You can configure {es} to automatically determine its addresses by using the
  67. following special values. Use these values when configuring
  68. `network.host`, `network.bind_host`, `network.publish_host`, and the
  69. corresponding settings for the HTTP and transport interfaces.
  70. `_local_`::
  71. Any loopback addresses on the system, for example `127.0.0.1`.
  72. `_site_`::
  73. Any site-local addresses on the system, for example `192.168.0.1`.
  74. `_global_`::
  75. Any globally-scoped addresses on the system, for example `8.8.8.8`.
  76. `_[networkInterface]_`::
  77. Use the addresses of the network interface called `[networkInterface]`. For
  78. example if you wish to use the addresses of an interface called `en0` then
  79. set `network.host: _en0_`.
  80. `0.0.0.0`::
  81. The addresses of all available network interfaces.
  82. NOTE: In some systems these special values resolve to multiple addresses. If
  83. so, {es} will select one of them as its publish address and may change its
  84. selection on each node restart. Ensure your node is accessible at every possible
  85. address.
  86. NOTE: Any values containing a `:` (e.g. an IPv6 address or some of the
  87. <<network-interface-values,special values>>) must be quoted because `:` is a
  88. special character in YAML.
  89. [[network-interface-values-ipv4-vs-ipv6]]
  90. ===== IPv4 vs IPv6
  91. These special values yield both IPv4 and IPv6 addresses by default, but you can
  92. also add an `:ipv4` or `:ipv6` suffix to limit them to just IPv4 or IPv6
  93. addresses respectively. For example, `network.host: "_en0:ipv4_"` would set this
  94. node's addresses to the IPv4 addresses of interface `en0`.
  95. [TIP]
  96. .Discovery in the Cloud
  97. ================================
  98. More special settings are available when running in the Cloud with either the
  99. {plugins}/discovery-ec2.html[EC2 discovery plugin] or the
  100. {plugins}/discovery-gce-network-host.html#discovery-gce-network-host[Google Compute Engine discovery plugin]
  101. installed.
  102. ================================
  103. [[modules-network-binding-publishing]]
  104. ==== Binding and publishing
  105. {es} uses network addresses for two distinct purposes known as binding and
  106. publishing. Most nodes will use the same address for everything, but more
  107. complicated setups may need to configure different addresses for different
  108. purposes.
  109. When an application such as {es} wishes to receive network communications, it
  110. must indicate to the operating system the address or addresses whose traffic it
  111. should receive. This is known as _binding_ to those addresses. {es} can bind to
  112. more than one address if needed, but most nodes only bind to a single address.
  113. {es} can only bind to an address if it is running on a host that has a network
  114. interface with that address. If necessary, you can configure the transport and
  115. HTTP interfaces to bind to different addresses.
  116. Each {es} node has an address at which clients and other nodes can contact it,
  117. known as its _publish address_. Each node has one publish address for its HTTP
  118. interface and one for its transport interface. These two addresses can be
  119. anything, and don't need to be addresses of the network interfaces on the host.
  120. The only requirements are that each node must be:
  121. * Accessible at its HTTP publish address by all clients that will discover it
  122. using sniffing.
  123. * Accessible at its transport publish address by all other nodes in its
  124. cluster, and by any remote clusters that will discover it using
  125. <<sniff-mode,sniff mode>>.
  126. Each node must have its own distinct publish address.
  127. If you specify the transport publish address using a hostname then {es} will
  128. resolve this hostname to an IP address once during startup, and other nodes
  129. will use the resulting IP address instead of resolving the name again
  130. themselves. You must use a hostname such that all of the addresses to which it
  131. resolves are addresses at which the node is accessible from all other nodes. To
  132. avoid confusion, it is simplest to use a hostname which resolves to a single
  133. address.
  134. If you specify the transport publish address using a
  135. <<network-interface-values,special value>> then {es} will resolve this value to
  136. a single IP address during startup, and other nodes will use the resulting IP
  137. address instead of resolving the value again themselves. You must use a value
  138. such that all of the addresses to which it resolves are addresses at which the
  139. node is accessible from all other nodes. To avoid confusion, it is simplest to
  140. use a value which resolves to a single address. It is usually a mistake to use
  141. `0.0.0.0` as a publish address on hosts with more than one network interface.
  142. ===== Using a single address
  143. The most common configuration is for {es} to bind to a single address at which
  144. it is accessible to clients and other nodes. To use this configuration, set
  145. only `network.host` to the desired address. Do not separately set any bind or
  146. publish addresses. Do not separately specify the addresses for the HTTP or
  147. transport interfaces.
  148. ===== Using multiple addresses
  149. Use the <<advanced-network-settings, advanced network settings>> if you wish to
  150. bind {es} to multiple addresses, or to publish a different address from the
  151. addresses to which you are binding. Set `network.bind_host` to the bind
  152. addresses, and `network.publish_host` to the address at which this node is
  153. exposed. In complex configurations, you can configure these addresses
  154. differently for the HTTP and transport interfaces.
  155. [[advanced-network-settings]]
  156. ==== Advanced network settings
  157. These advanced settings let you bind to multiple addresses, or to use different
  158. addresses for binding and publishing. They are not required in most cases and
  159. you should not use them if you can use the <<common-network-settings,commonly
  160. used settings>> instead.
  161. `network.bind_host`::
  162. (<<static-cluster-setting,Static>>, string)
  163. The network address(es) to which the node should bind in order to listen for
  164. incoming connections. Accepts a list of IP addresses, hostnames, and
  165. <<network-interface-values,special values>>. Defaults to the address given by
  166. `network.host`. Use this setting only if binding to multiple addresses or using
  167. different addresses for publishing and binding.
  168. `network.publish_host`::
  169. (<<static-cluster-setting,Static>>, string)
  170. The network address that clients and other nodes can use to contact this node.
  171. Accepts an IP address, a hostname, or a <<network-interface-values,special
  172. value>>. Defaults to the address given by `network.host`. Use this setting only
  173. if binding to multiple addresses or using different addresses for publishing
  174. and binding.
  175. NOTE: You can specify a list of addresses for `network.host` and
  176. `network.publish_host`. You can also specify one or more hostnames or
  177. <<network-interface-values,special values>> that resolve to multiple addresses.
  178. If you do this then {es} chooses one of the addresses for its publish address.
  179. This choice uses heuristics based on IPv4/IPv6 stack preference and
  180. reachability and may change when the node restarts. Ensure
  181. each node is accessible at all possible publish addresses.
  182. [[tcp-settings]]
  183. ===== Advanced TCP settings
  184. Use the following settings to control the low-level parameters of the TCP
  185. connections used by the HTTP and transport interfaces.
  186. `network.tcp.keep_alive`::
  187. (<<static-cluster-setting,Static>>, boolean)
  188. Configures the `SO_KEEPALIVE` option for network sockets, which determines
  189. whether each connection sends TCP keepalive probes. Defaults to `true`.
  190. `network.tcp.keep_idle`::
  191. (<<static-cluster-setting,Static>>, integer)
  192. Configures the `TCP_KEEPIDLE` option for network sockets, which determines the
  193. time in seconds that a connection must be idle before starting to send TCP
  194. keepalive probes. Defaults to `-1`, which means to use the system default. This
  195. value cannot exceed `300` seconds. Only applicable on Linux and macOS.
  196. `network.tcp.keep_interval`::
  197. (<<static-cluster-setting,Static>>, integer)
  198. Configures the `TCP_KEEPINTVL` option for network sockets, which determines the
  199. time in seconds between sending TCP keepalive probes. Defaults to `-1`, which
  200. means to use the system default. This value cannot exceed `300` seconds. Only
  201. applicable on Linux and macOS.
  202. `network.tcp.keep_count`::
  203. (<<static-cluster-setting,Static>>, integer)
  204. Configures the `TCP_KEEPCNT` option for network sockets, which determines the
  205. number of unacknowledged TCP keepalive probes that may be sent on a connection
  206. before it is dropped. Defaults to `-1`, which means to use the system default.
  207. Only applicable on Linux and macOS.
  208. `network.tcp.no_delay`::
  209. (<<static-cluster-setting,Static>>, boolean)
  210. Configures the `TCP_NODELAY` option on network sockets, which determines
  211. whether {wikipedia}/Nagle%27s_algorithm[TCP no delay] is enabled. Defaults to
  212. `true`.
  213. `network.tcp.reuse_address`::
  214. (<<static-cluster-setting,Static>>, boolean)
  215. Configures the `SO_REUSEADDR` option for network sockets, which determines
  216. whether the address can be reused or not. Defaults to `false` on Windows and
  217. `true` otherwise.
  218. `network.tcp.send_buffer_size`::
  219. (<<static-cluster-setting,Static>>, <<byte-units,byte value>>)
  220. Configures the size of the TCP send buffer for network sockets. Defaults to
  221. `-1` which means to use the system default.
  222. `network.tcp.receive_buffer_size`::
  223. (<<static-cluster-setting,Static>>, <<byte-units,byte value>>)
  224. Configures the size of the TCP receive buffer. Defaults to `-1` which means to
  225. use the system default.
  226. include::http.asciidoc[]
  227. include::transport.asciidoc[]
  228. include::remote-cluster-network.asciidoc[]
  229. include::network/tracers.asciidoc[]
  230. include::network/threading.asciidoc[]
  231. [[readiness-tcp-port]]
  232. ==== TCP readiness port
  233. preview::[]
  234. If configured, a node can open a TCP port when the node is in a ready state. A node is deemed
  235. ready when it has successfully joined a cluster. In a single node configuration, the node is
  236. said to be ready, when it's able to accept requests.
  237. To enable the readiness TCP port, use the `readiness.port` setting. The readiness service will bind to
  238. all host addresses.
  239. If the node leaves the cluster, or the <<put-shutdown,Shutdown API>> is used to mark the node
  240. for shutdown, the readiness port is immediately closed.
  241. A successful connection to the readiness TCP port signals that the {es} node is ready. When a client
  242. connects to the readiness port, the server simply terminates the socket connection. No data is sent back
  243. to the client. If a client cannot connect to the readiness port, the node is not ready.