remote-clusters.asciidoc 13 KB

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