remote-clusters.asciidoc 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. "transport.ping_schedule": "30s"
  99. },
  100. "cluster_two": {
  101. "mode": "sniff",
  102. "seeds": [
  103. "127.0.0.1:9301"
  104. ],
  105. "transport.compress": true,
  106. "skip_unavailable": true
  107. },
  108. "cluster_three": {
  109. "mode": "proxy",
  110. "proxy_address": "127.0.0.1:9302"
  111. }
  112. }
  113. }
  114. }
  115. }
  116. --------------------------------
  117. // TEST[setup:host]
  118. // TEST[s/127.0.0.1:9300/\${transport_host}/]
  119. You can dynamically update the compression and ping schedule settings. However,
  120. you must re-include seeds or `proxy_address` in the settings update request.
  121. For example:
  122. [source,console]
  123. --------------------------------
  124. PUT _cluster/settings
  125. {
  126. "persistent": {
  127. "cluster": {
  128. "remote": {
  129. "cluster_one": {
  130. "seeds": [
  131. "127.0.0.1:9300"
  132. ],
  133. "transport.ping_schedule": "60s"
  134. },
  135. "cluster_two": {
  136. "mode": "sniff",
  137. "seeds": [
  138. "127.0.0.1:9301"
  139. ],
  140. "transport.compress": false
  141. },
  142. "cluster_three": {
  143. "mode": "proxy",
  144. "proxy_address": "127.0.0.1:9302",
  145. "transport.compress": true
  146. }
  147. }
  148. }
  149. }
  150. }
  151. --------------------------------
  152. // TEST[continued]
  153. NOTE: When the compression or ping schedule settings change, all the existing
  154. node connections must close and re-open, which can cause in-flight requests to
  155. fail.
  156. You can delete a remote cluster from the cluster settings by passing `null`
  157. values for each remote cluster setting:
  158. [source,console]
  159. --------------------------------
  160. PUT _cluster/settings
  161. {
  162. "persistent": {
  163. "cluster": {
  164. "remote": {
  165. "cluster_two": { <1>
  166. "mode": null,
  167. "seeds": null,
  168. "skip_unavailable": null,
  169. "transport": {
  170. "compress": null
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. --------------------------------
  178. // TEST[continued]
  179. <1> `cluster_two` would be removed from the cluster settings, leaving
  180. `cluster_one` and `cluster_three` intact.
  181. [discrete]
  182. [[configure-remote-clusters-static]]
  183. ===== Statically configure remote clusters
  184. If you specify settings in `elasticsearch.yml` files, only the nodes with
  185. those settings can connect to the remote cluster and serve remote cluster requests. For example:
  186. [source,yaml]
  187. --------------------------------
  188. cluster:
  189. remote:
  190. cluster_one: <1>
  191. seeds: 127.0.0.1:9300 <2>
  192. transport.ping_schedule: 30s <3>
  193. cluster_two: <1>
  194. mode: sniff <4>
  195. seeds: 127.0.0.1:9301 <2>
  196. transport.compress: true <5>
  197. skip_unavailable: true <6>
  198. cluster_three: <1>
  199. mode: proxy <4>
  200. proxy_address: 127.0.0.1:9302 <7>
  201. --------------------------------
  202. <1> `cluster_one`, `cluster_two`, and `cluster_three` are arbitrary _cluster aliases_
  203. representing the connection to each cluster. These names are subsequently used to
  204. distinguish between local and remote indices.
  205. <2> The hostname and <<transport-settings,transport port>> (default: 9300) of a
  206. seed node in the remote cluster.
  207. <3> A keep-alive ping is configured for `cluster_one`.
  208. <4> The configured connection mode. By default, this is <<sniff-mode,`sniff`>>, so
  209. the mode is implicit for `cluster_one`. However, it can be explicitly configured
  210. as demonstrated by `cluster_two` and must be explicitly configured for
  211. <<proxy-mode,proxy mode>> as demonstrated by `cluster_three`.
  212. <5> Compression is explicitly enabled for requests to `cluster_two`.
  213. <6> Disconnected remote clusters are optional for `cluster_two`.
  214. <7> The address for the proxy endpoint used to connect to `cluster_three`.
  215. [discrete]
  216. [[remote-cluster-settings]]
  217. === Global remote cluster settings
  218. These settings apply to both <<sniff-mode,sniff mode>> and
  219. <<proxy-mode,proxy mode>>. <<remote-cluster-sniff-settings,Sniff mode settings>>
  220. and <<remote-cluster-proxy-settings,proxy mode settings>> are described
  221. separately.
  222. `cluster.remote.<cluster_alias>.mode`::
  223. The mode used for a remote cluster connection. The only supported modes are
  224. `sniff` and `proxy`.
  225. `cluster.remote.initial_connect_timeout`::
  226. The time to wait for remote connections to be established when the node
  227. starts. The default is `30s`.
  228. `remote_cluster_client` <<node-roles,role>>::
  229. By default, any node in the cluster can act as a cross-cluster client and
  230. connect to remote clusters. To prevent a node from connecting to remote
  231. clusters, specify the <<node-roles,node.roles>> setting in `elasticsearch.yml`
  232. and exclude `remote_cluster_client` from the listed roles. Search requests
  233. targeting remote clusters must be sent to a node that is allowed to act as a
  234. cross-cluster client. Other features such as {ml} <<general-ml-settings,data
  235. feeds>>, <<general-transform-settings,transforms>>, and
  236. <<ccr-getting-started,{ccr}>> require the `remote_cluster_client` role.
  237. `cluster.remote.<cluster_alias>.skip_unavailable`::
  238. Per cluster boolean setting that allows to skip specific clusters when no
  239. nodes belonging to them are available and they are the target of a remote
  240. cluster request. Default is `false`, meaning that all clusters are mandatory
  241. by default, but they can selectively be made optional by setting this setting
  242. to `true`.
  243. `cluster.remote.<cluster_alias>.transport.ping_schedule`::
  244. Sets the time interval between regular application-level ping messages that
  245. are sent to ensure that transport connections to nodes belonging to remote
  246. clusters are kept alive. If set to `-1`, application-level ping messages to
  247. this remote cluster are not sent. If unset, application-level ping messages
  248. are sent according to the global `transport.ping_schedule` setting, which
  249. defaults to `-1` meaning that pings are not sent.
  250. `cluster.remote.<cluster_alias>.transport.compress`::
  251. Per cluster boolean setting that enables you to configure compression for
  252. requests 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. If unset, the global
  255. `transport.compress` is used as the fallback setting.
  256. [discrete]
  257. [[remote-cluster-sniff-settings]]
  258. === Sniff mode remote cluster settings
  259. `cluster.remote.<cluster_alias>.seeds`::
  260. The list of seed nodes used to sniff the remote cluster state.
  261. `cluster.remote.<cluster_alias>.node_connections`::
  262. The number of gateway nodes to connect to for this remote cluster. The default
  263. is `3`.
  264. `cluster.remote.node.attr`::
  265. A node attribute to filter out nodes that are eligible as a gateway node in
  266. the remote cluster. For instance a node can have a node attribute
  267. `node.attr.gateway: true` such that only nodes with this attribute will be
  268. connected to if `cluster.remote.node.attr` is set to `gateway`.
  269. [discrete]
  270. [[remote-cluster-proxy-settings]]
  271. === Proxy mode remote cluster settings
  272. `cluster.remote.<cluster_alias>.proxy_address`::
  273. The address used for all remote connections.
  274. `cluster.remote.<cluster_alias>.proxy_socket_connections`::
  275. The number of socket connections to open per remote cluster. The default is
  276. `18`.
  277. [role="xpack"]
  278. `cluster.remote.<cluster_alias>.server_name`::
  279. An optional hostname string which is sent in the `server_name` field of
  280. the TLS Server Name Indication extension if
  281. <<configuring-tls,TLS is enabled>>. The TLS transport will fail to open
  282. remote connections if this field is not a valid hostname as defined by the
  283. TLS SNI specification.