remote-clusters.asciidoc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. [[modules-remote-clusters]]
  2. == Remote clusters
  3. The _remote clusters_ functionality enables you to establish unidirectional
  4. connections to a remote cluster. Remote clusters are required for
  5. <<xpack-ccr,{ccr}>> and <<modules-cross-cluster-search,{ccs}>>.
  6. Remote cluster connections work by configuring a remote cluster and connecting
  7. to a limited number of nodes in that remote cluster. There are two modes for
  8. remote cluster connections: <<sniff-mode,sniff mode>> and
  9. <<proxy-mode,proxy mode>>.
  10. Communication with a remote cluster uses the <<modules-transport,transport
  11. layer>> to establish a number of <<long-lived-connections,long-lived>> TCP
  12. connections from the coordinating nodes of the local cluster to the chosen
  13. nodes in the remote cluster.
  14. [discrete]
  15. [[sniff-mode]]
  16. === Sniff mode
  17. In sniff mode, a cluster is created using a name and a list of seed nodes. When
  18. a remote cluster is registered, its cluster state is retrieved from one of the
  19. seed nodes and up to three _gateway nodes_ are selected as part of remote
  20. cluster requests. This mode requires that the gateway node's publish addresses
  21. are accessible by the local cluster.
  22. Sniff mode is the default connection mode.
  23. [discrete]
  24. [[gateway-nodes-selection]]
  25. ==== Gateway nodes selection
  26. The _gateway nodes_ selection depends on the following criteria:
  27. - *version*: Remote nodes must be compatible with the cluster they are
  28. registered to. This is subject to rules that are similar to those for
  29. <<rolling-upgrades>>. Any node can communicate with any other node on the same
  30. major version (e.g. 7.0 can talk to any 7.x node). Only nodes on the last minor
  31. version of a certain major version can communicate with nodes on the following
  32. major version. Note that in the 6.x series, 6.8 can communicate with any 7.x
  33. node, while 6.7 can only communicate with 7.0. Version compatibility is
  34. symmetric, meaning that if 6.7 can communicate with 7.0, 7.0 can also
  35. communicate with 6.7. The matrix below summarizes compatibility as described above.
  36. // tag::remote-cluster-compatibility-matrix[]
  37. [cols="^,^,^,^,^,^,^,^"]
  38. |====
  39. | 7+^h| Local cluster
  40. h| Remote cluster | 5.0->5.5 | 5.6 | 6.0->6.6 | 6.7 | 6.8 | 7.0 | 7.1->7.x
  41. | 5.0->5.5 | {yes-icon} | {yes-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {no-icon}
  42. | 5.6 | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {no-icon} | {no-icon}
  43. | 6.0->6.6 | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {no-icon} | {no-icon}
  44. | 6.7 | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {no-icon}
  45. | 6.8 | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}
  46. | 7.0 | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon} | {yes-icon}
  47. | 7.1->7.x | {no-icon} | {no-icon} | {no-icon} | {no-icon} | {yes-icon} | {yes-icon} | {yes-icon}
  48. |====
  49. // end::remote-cluster-compatibility-matrix[]
  50. - *role*: Dedicated master nodes never get selected.
  51. - *attributes*: You can tag which nodes should be selected
  52. (see <<remote-cluster-settings>>), though such tagged nodes still have
  53. to satisfy the two above requirements.
  54. [discrete]
  55. [[proxy-mode]]
  56. === Proxy mode
  57. In proxy mode, a cluster is created using a name and a single proxy address. When
  58. a remote cluster is registered, a configurable number of socket connections are
  59. opened to the proxy address. The proxy is required to route those connections to
  60. the remote cluster. Proxy mode does not require remote cluster nodes to have
  61. accessible publish addresses.
  62. The proxy mode is not the default connection mode and must be configured. Similar
  63. to the sniff <<gateway-nodes-selection,gateway nodes>>, the remote
  64. connections are subject to the same version compatibility rules as
  65. <<rolling-upgrades>>.
  66. [discrete]
  67. [[configuring-remote-clusters]]
  68. ==== Configuring remote clusters
  69. You can configure remote clusters globally by using
  70. <<cluster-update-settings,cluster settings>>, which you can update dynamically.
  71. Alternatively, you can configure them locally on individual nodes by using the
  72. `elasticsearch.yml` file.
  73. If you specify the settings in `elasticsearch.yml` files, only the nodes with
  74. those settings can connect to the remote cluster. In other words, functionality
  75. that relies on remote cluster requests must be driven specifically from those
  76. nodes. For example:
  77. [source,yaml]
  78. --------------------------------
  79. cluster:
  80. remote:
  81. cluster_one: <1>
  82. seeds: 127.0.0.1:9300 <2>
  83. transport.ping_schedule: 30s <3>
  84. cluster_two: <1>
  85. mode: sniff <4>
  86. seeds: 127.0.0.1:9301 <2>
  87. transport.compress: true <5>
  88. skip_unavailable: true <6>
  89. cluster_three: <1>
  90. mode: proxy <4>
  91. proxy_address: 127.0.0.1:9302 <7>
  92. --------------------------------
  93. <1> `cluster_one`, `cluster_two`, and `cluster_three` are arbitrary _cluster aliases_
  94. representing the connection to each cluster. These names are subsequently used to
  95. distinguish between local and remote indices.
  96. <2> The hostname and <<modules-transport,transport>> port (default: 9300) of a
  97. seed node in the remote cluster.
  98. <3> A keep-alive ping is configured for `cluster_one`.
  99. <4> The configured connection mode. By default, this is <<sniff-mode,`sniff`>>, so
  100. the mode is implicit for `cluster_one`. However, it can be explicitly configured
  101. as demonstrated by `cluster_two` and must be explicitly configured for
  102. <<proxy-mode,proxy mode>> as demonstrated by `cluster_three`.
  103. <5> Compression is explicitly enabled for requests to `cluster_two`.
  104. <6> Disconnected remote clusters are optional for `cluster_two`.
  105. <7> The address for the proxy endpoint used to connect to `cluster_three`.
  106. For more information about the optional transport settings, see
  107. <<modules-transport>>.
  108. If you use <<cluster-update-settings,cluster settings>>, the remote clusters
  109. are available on every node in the cluster. For example:
  110. [source,console]
  111. --------------------------------
  112. PUT _cluster/settings
  113. {
  114. "persistent": {
  115. "cluster": {
  116. "remote": {
  117. "cluster_one": {
  118. "seeds": [
  119. "127.0.0.1:9300"
  120. ],
  121. "transport.ping_schedule": "30s"
  122. },
  123. "cluster_two": {
  124. "mode": "sniff",
  125. "seeds": [
  126. "127.0.0.1:9301"
  127. ],
  128. "transport.compress": true,
  129. "skip_unavailable": true
  130. },
  131. "cluster_three": {
  132. "mode": "proxy",
  133. "proxy_address": "127.0.0.1:9302"
  134. }
  135. }
  136. }
  137. }
  138. }
  139. --------------------------------
  140. // TEST[setup:host]
  141. // TEST[s/127.0.0.1:9300/\${transport_host}/]
  142. You can dynamically update the compression and ping schedule settings. However,
  143. you must re-include seeds or `proxy_address` in the settings update request.
  144. For example:
  145. [source,console]
  146. --------------------------------
  147. PUT _cluster/settings
  148. {
  149. "persistent": {
  150. "cluster": {
  151. "remote": {
  152. "cluster_one": {
  153. "seeds": [
  154. "127.0.0.1:9300"
  155. ],
  156. "transport.ping_schedule": "60s"
  157. },
  158. "cluster_two": {
  159. "mode": "sniff",
  160. "seeds": [
  161. "127.0.0.1:9301"
  162. ],
  163. "transport.compress": false
  164. },
  165. "cluster_three": {
  166. "mode": "proxy",
  167. "proxy_address": "127.0.0.1:9302",
  168. "transport.compress": true
  169. }
  170. }
  171. }
  172. }
  173. }
  174. --------------------------------
  175. // TEST[continued]
  176. NOTE: When the compression or ping schedule settings change, all the existing
  177. node connections must close and re-open, which can cause in-flight requests to
  178. fail.
  179. A remote cluster can be deleted from the cluster settings by setting its settings to `null` :
  180. [source,console]
  181. --------------------------------
  182. PUT _cluster/settings
  183. {
  184. "persistent": {
  185. "cluster": {
  186. "remote": {
  187. "cluster_two": { <1>
  188. "mode": null,
  189. "seeds": null,
  190. "skip_unavailable": null,
  191. "transport": {
  192. "compress": null
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. --------------------------------
  200. // TEST[continued]
  201. <1> `cluster_two` would be removed from the cluster settings, leaving
  202. `cluster_one` and `cluster_three` intact.
  203. [discrete]
  204. [[remote-cluster-settings]]
  205. === Remote cluster settings for all modes
  206. These settings apply to both <<sniff-mode,sniff mode>> and
  207. <<proxy-mode,proxy mode>>. <<remote-cluster-sniff-settings,Sniff mode settings>>
  208. and <<remote-cluster-proxy-settings,proxy mode settings>> are described below.
  209. `cluster.remote.<cluster_alias>.mode`::
  210. The mode used for a remote cluster connection. The only supported modes are
  211. `sniff` and `proxy`.
  212. `cluster.remote.initial_connect_timeout`::
  213. The time to wait for remote connections to be established when the node
  214. starts. The default is `30s`.
  215. `node.remote_cluster_client`::
  216. By default, any node in the cluster can act as a cross-cluster client and
  217. connect to remote clusters. The `node.remote_cluster_client` setting can be
  218. set to `false` (defaults to `true`) to prevent certain nodes from connecting
  219. to remote clusters. Remote cluster requests must be sent to a node that is
  220. allowed to act as a cross-cluster client.
  221. `cluster.remote.<cluster_alias>.skip_unavailable`::
  222. Per cluster boolean setting that allows to skip specific clusters when no
  223. nodes belonging to them are available and they are the target of a remote
  224. cluster request. Default is `false`, meaning that all clusters are mandatory
  225. by default, but they can selectively be made optional by setting this setting
  226. to `true`.
  227. `cluster.remote.<cluster_alias>.transport.ping_schedule`::
  228. Sets the time interval between regular application-level ping messages that
  229. are sent to ensure that transport connections to nodes belonging to remote
  230. clusters are kept alive. If set to `-1`, application-level ping messages to
  231. this remote cluster are not sent. If unset, application-level ping messages
  232. are sent according to the global `transport.ping_schedule` setting, which
  233. defaults to `-1` meaning that pings are not sent.
  234. `cluster.remote.<cluster_alias>.transport.compress`::
  235. Per cluster boolean setting that enables you to configure compression for
  236. requests to a specific remote cluster. This setting impacts only requests
  237. sent to the remote cluster. If the inbound request is compressed,
  238. Elasticsearch compresses the response. If unset, the global
  239. `transport.compress` is used as the fallback setting.
  240. [discrete]
  241. [[remote-cluster-sniff-settings]]
  242. === Remote cluster settings for sniff mode
  243. `cluster.remote.<cluster_alias>.seeds`::
  244. The list of seed nodes used to sniff the remote cluster state.
  245. `cluster.remote.<cluster_alias>.node_connections`::
  246. The number of gateway nodes to connect to for this remote cluster. The default
  247. is `3`.
  248. `cluster.remote.node.attr`::
  249. A node attribute to filter out nodes that are eligible as a gateway node in
  250. the remote cluster. For instance a node can have a node attribute
  251. `node.attr.gateway: true` such that only nodes with this attribute will be
  252. connected to if `cluster.remote.node.attr` is set to `gateway`.
  253. [discrete]
  254. [[remote-cluster-proxy-settings]]
  255. === Remote cluster settings for proxy mode
  256. `cluster.remote.<cluster_alias>.proxy_address`::
  257. The address used for all remote connections.
  258. `cluster.remote.<cluster_alias>.proxy_socket_connections`::
  259. The number of socket connections to open per remote cluster. The default is
  260. `18`.
  261. [role="xpack"]
  262. `cluster.remote.<cluster_alias>.server_name`::
  263. An optional hostname string which is sent in the `server_name` field of
  264. the TLS Server Name Indication extension if
  265. <<configuring-tls,TLS is enabled>>. The TLS transport will fail to open
  266. remote connections if this field is not a valid hostname as defined by the
  267. TLS SNI specification.
  268. [discrete]
  269. [[retrieve-remote-clusters-info]]
  270. === Retrieving remote clusters info
  271. You can use the <<cluster-remote-info, remote cluster info API>> to retrieve
  272. information about the configured remote clusters, as well as the remote nodes
  273. that the node is connected to.