remote-clusters.asciidoc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. [[modules-remote-clusters]]
  2. == Remote clusters
  3. ifndef::include-xpack[]
  4. The _remote clusters_ module enables you to establish uni-directional
  5. connections to a remote cluster. This functionality is used in
  6. <<modules-cross-cluster-search,cross-cluster search>>.
  7. endif::[]
  8. ifdef::include-xpack[]
  9. The _remote clusters_ module enables you to establish uni-directional
  10. connections to a remote cluster. This functionality is used in
  11. {stack-ov}/xpack-ccr.html[{ccr}] and
  12. <<modules-cross-cluster-search,cross-cluster search>>.
  13. endif::[]
  14. Remote cluster connections work by configuring a remote cluster and connecting
  15. only to a limited number of nodes in the remote cluster. Each remote cluster is
  16. referenced by a name and a list of seed nodes. When a remote cluster is
  17. registered, its cluster state is retrieved from one of the seed nodes so that by
  18. default up to three _gateway nodes_ are selected to be connected to as part of
  19. remote cluster requests. Remote cluster connections consist of uni-directional
  20. connections from the coordinating node to the previously selected remote nodes
  21. only. You can tag which nodes should be selected by using node attributes (see <<remote-cluster-settings>>).
  22. Each node in a cluster that has remote clusters configured connects to one or
  23. more _gateway nodes_ and uses them to federate requests to the remote cluster.
  24. [float]
  25. [[configuring-remote-clusters]]
  26. === Configuring remote clusters
  27. You can configure remote clusters globally by using
  28. <<cluster-update-settings,cluster settings>>, which you can update dynamically.
  29. Alternatively, you can configure them locally on individual nodes by using the `elasticsearch.yml` file.
  30. If you specify the settings in `elasticsearch.yml` files, only the nodes with
  31. those settings can connect to the remote cluster. In other words, functionality
  32. that relies on remote cluster requests must be driven specifically from those
  33. nodes. For example:
  34. [source,yaml]
  35. --------------------------------
  36. cluster:
  37. remote:
  38. cluster_one: <1>
  39. seeds: 127.0.0.1:9300
  40. transport.ping_schedule: 30s <2>
  41. cluster_two:
  42. seeds: 127.0.0.1:9301
  43. transport.compress: true <3>
  44. --------------------------------
  45. <1> `cluster_one` and `cluster_two` are arbitrary _cluster aliases_ representing
  46. the connection to each cluster. These names are subsequently used to distinguish
  47. between local and remote indices.
  48. <2> A keep-alive ping is configured for `cluster_one`.
  49. <3> Compression is explicitly enabled for requests to `cluster_two`.
  50. For more information about the optional transport settings, see
  51. <<modules-transport>>.
  52. If you use <<cluster-update-settings,cluster settings>>, the remote clusters are available on every node in the cluster. For example:
  53. [source,js]
  54. --------------------------------
  55. PUT _cluster/settings
  56. {
  57. "persistent": {
  58. "cluster": {
  59. "remote": {
  60. "cluster_one": {
  61. "seeds": [
  62. "127.0.0.1:9300"
  63. ],
  64. "transport.ping_schedule": "30s"
  65. },
  66. "cluster_two": {
  67. "seeds": [
  68. "127.0.0.1:9301"
  69. ],
  70. "transport.compress": true
  71. },
  72. "cluster_three": {
  73. "seeds": [
  74. "127.0.0.1:9302"
  75. ]
  76. }
  77. }
  78. }
  79. }
  80. }
  81. --------------------------------
  82. // CONSOLE
  83. // TEST[setup:host]
  84. // TEST[s/127.0.0.1:9300/\${transport_host}/]
  85. You can dynamically update the compression and ping schedule settings. However,
  86. you must re-include seeds in the settings update request. For example:
  87. [source,js]
  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": "60s"
  99. },
  100. "cluster_two": {
  101. "seeds": [
  102. "127.0.0.1:9301"
  103. ],
  104. "transport.compress": false
  105. }
  106. }
  107. }
  108. }
  109. }
  110. --------------------------------
  111. // CONSOLE
  112. // TEST[continued]
  113. NOTE: When the compression or ping schedule settings change, all the existing
  114. node connections must close and re-open, which can cause in-flight requests to
  115. fail.
  116. A remote cluster can be deleted from the cluster settings by setting its seeds
  117. to `null`:
  118. [source,js]
  119. --------------------------------
  120. PUT _cluster/settings
  121. {
  122. "persistent": {
  123. "cluster": {
  124. "remote": {
  125. "cluster_three": {
  126. "seeds": null <1>
  127. }
  128. }
  129. }
  130. }
  131. }
  132. --------------------------------
  133. // CONSOLE
  134. // TEST[continued]
  135. <1> `cluster_three` would be removed from the cluster settings, leaving
  136. `cluster_one` and `cluster_two` intact.
  137. [float]
  138. [[remote-cluster-settings]]
  139. === Remote cluster settings
  140. `cluster.remote.connections_per_cluster`::
  141. The number of gateway nodes to connect to per remote cluster. The default is
  142. `3`.
  143. `cluster.remote.initial_connect_timeout`::
  144. The time to wait for remote connections to be established when the node
  145. starts. The default is `30s`.
  146. `cluster.remote.node.attr`::
  147. A node attribute to filter out nodes that are eligible as a gateway node in
  148. the remote cluster. For instance a node can have a node attribute
  149. `node.attr.gateway: true` such that only nodes with this attribute will be
  150. connected to if `cluster.remote.node.attr` is set to `gateway`.
  151. `cluster.remote.connect`::
  152. By default, any node in the cluster can act as a cross-cluster client and
  153. connect to remote clusters. The `cluster.remote.connect` setting can be set to
  154. `false` (defaults to `true`) to prevent certain nodes from connecting to
  155. remote clusters. Remote cluster requests must be sent to a node that is
  156. allowed to act as a cross-cluster client.
  157. `cluster.remote.${cluster_alias}.skip_unavailable`::
  158. Per cluster boolean setting that allows to skip specific clusters when no
  159. nodes belonging to them are available and they are the targetof a remote
  160. cluster request. Default is `false`, meaning that all clusters are mandatory
  161. by default, but they can selectively be made optional by setting this setting
  162. to `true`.
  163. `cluster.remote.${cluster_alias}.transport.ping_schedule`::
  164. Sets the time interval between regular application-level ping messages that
  165. are sent to ensure that transport connections to nodes belonging to remote
  166. clusters are kept alive. If set to `-1`, application-level ping messages to
  167. this remote cluster are not sent. If unset, application-level ping messages
  168. are sent according to the global `transport.ping_schedule` setting, which
  169. defaults to ``-1` meaning that pings are not sent.
  170. `cluster.remote.${cluster_alias}.transport.compress`::
  171. Per cluster boolean setting that enables you to configure compression for
  172. requests to a specific remote cluster. This setting impacts only requests
  173. sent to the remote cluster. If the inbound request is compressed,
  174. Elasticsearch compresses the response. If unset, the global
  175. `transport.compress` is used as the fallback setting.
  176. [float]
  177. [[retrieve-remote-clusters-info]]
  178. === Retrieving remote clusters info
  179. You can use the <<cluster-remote-info, remote cluster info API>> to retrieve
  180. information about the configured remote clusters, as well as the remote nodes
  181. that the node is connected to.