remote-clusters-connect.asciidoc 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. [[remote-clusters-connect]]
  2. === Connect to remote clusters
  3. Your local cluster uses the <<modules-network,transport interface>> to establish
  4. communication with remote clusters. The coordinating nodes in the local cluster
  5. establish <<long-lived-connections,long-lived>> TCP connections with specific
  6. nodes in the remote cluster. {es} requires these connections to remain open,
  7. even if the connections are idle for an extended period.
  8. NOTE: You must have the `manage` cluster privilege to connect remote clusters.
  9. To add a remote cluster from Stack Management in {kib}:
  10. . Select *Remote Clusters* from the side navigation.
  11. . Specify the {es} endpoint URL, or the IP address or host name of the remote
  12. cluster followed by the transport port (defaults to `9300`). For example,
  13. `cluster.es.eastus2.staging.azure.foundit.no:9400` or `192.168.1.1:9300`.
  14. Alternatively, use the <<cluster-update-settings,cluster update settings API>>
  15. to add a remote cluster. You can also use this API to
  16. <<configure-remote-clusters-dynamic,dynamically configure>> remote clusters for
  17. _every_ node in the local cluster. To configure remote clusters on individual
  18. nodes in the local cluster, define
  19. <<configure-remote-clusters-static,static settings>> in `elasticsearch.yml` for
  20. each node.
  21. After connecting remote clusters,
  22. <<remote-clusters-privileges,configure roles and users for remote clusters>>.
  23. The following request adds a remote cluster with an alias of `cluster_one`. This
  24. _cluster alias_ is a unique identifier that represents the connection to the
  25. remote cluster and is used to distinguish between local and remote indices.
  26. [source,console]
  27. ----
  28. PUT /_cluster/settings
  29. {
  30. "persistent" : {
  31. "cluster" : {
  32. "remote" : {
  33. "cluster_one" : { <1>
  34. "seeds" : [
  35. "127.0.0.1:9300" <2>
  36. ]
  37. }
  38. }
  39. }
  40. }
  41. }
  42. ----
  43. // TEST[setup:host]
  44. // TEST[s/127.0.0.1:9300/\${transport_host}/]
  45. <1> The cluster alias of this remote cluster is `cluster_one`.
  46. <2> Specifies the hostname and transport port of a seed node in the remote
  47. cluster.
  48. You can use the <<cluster-remote-info,remote cluster info API>> to verify that
  49. the local cluster is successfully connected to the remote cluster:
  50. [source,console]
  51. ----
  52. GET /_remote/info
  53. ----
  54. // TEST[continued]
  55. The API response indicates that the local cluster is connected to the remote
  56. cluster with the cluster alias `cluster_one`:
  57. [source,console-result]
  58. ----
  59. {
  60. "cluster_one" : {
  61. "seeds" : [
  62. "127.0.0.1:9300"
  63. ],
  64. "connected" : true,
  65. "num_nodes_connected" : 1, <1>
  66. "max_connections_per_cluster" : 3,
  67. "initial_connect_timeout" : "30s",
  68. "skip_unavailable" : false, <2>
  69. "mode" : "sniff"
  70. }
  71. }
  72. ----
  73. // TESTRESPONSE[s/127.0.0.1:9300/$body.cluster_one.seeds.0/]
  74. // TEST[s/"connected" : true/"connected" : $body.cluster_one.connected/]
  75. // TEST[s/"num_nodes_connected" : 1/"num_nodes_connected" : $body.cluster_one.num_nodes_connected/]
  76. <1> The number of nodes in the remote cluster the local cluster is
  77. connected to.
  78. <2> Indicates whether to skip the remote cluster if searched through {ccs} but
  79. no nodes are available.
  80. [[configure-remote-clusters-dynamic]]
  81. ==== Dynamically configure remote clusters
  82. Use the <<cluster-update-settings,cluster update settings API>> to dynamically
  83. configure remote settings on every node in the cluster. The following request
  84. adds three remote clusters: `cluster_one`, `cluster_two`, and `cluster_three`.
  85. The `seeds` parameter specifies the hostname and
  86. <<transport-settings,transport port>> (default `9300`) of a seed node in the
  87. remote cluster.
  88. The `mode` parameter determines the configured connection mode, which defaults
  89. to <<sniff-mode,`sniff`>>. Because `cluster_one` doesn't specify a `mode`, it
  90. uses the default. Both `cluster_two` and `cluster_three` explicitly use
  91. different modes.
  92. [source,console]
  93. ----
  94. PUT _cluster/settings
  95. {
  96. "persistent": {
  97. "cluster": {
  98. "remote": {
  99. "cluster_one": {
  100. "seeds": [
  101. "127.0.0.1:9300"
  102. ]
  103. },
  104. "cluster_two": {
  105. "mode": "sniff",
  106. "seeds": [
  107. "127.0.0.1:9301"
  108. ],
  109. "transport.compress": true,
  110. "skip_unavailable": true
  111. },
  112. "cluster_three": {
  113. "mode": "proxy",
  114. "proxy_address": "127.0.0.1:9302"
  115. }
  116. }
  117. }
  118. }
  119. }
  120. ----
  121. // TEST[setup:host]
  122. // TEST[s/127.0.0.1:9300/\${transport_host}/]
  123. You can dynamically update settings for a remote cluster after the initial configuration. The following request updates the
  124. compression settings for `cluster_two`, and the compression and ping schedule
  125. settings for `cluster_three`.
  126. NOTE: When the compression or ping schedule settings change, all existing
  127. node connections must close and re-open, which can cause in-flight requests to
  128. fail.
  129. [source,console]
  130. ----
  131. PUT _cluster/settings
  132. {
  133. "persistent": {
  134. "cluster": {
  135. "remote": {
  136. "cluster_two": {
  137. "transport.compress": false
  138. },
  139. "cluster_three": {
  140. "transport.compress": true,
  141. "transport.ping_schedule": "60s"
  142. }
  143. }
  144. }
  145. }
  146. }
  147. ----
  148. // TEST[continued]
  149. You can delete a remote cluster from the cluster settings by passing `null`
  150. values for each remote cluster setting. The following request removes
  151. `cluster_two` from the cluster settings, leaving `cluster_one` and
  152. `cluster_three` intact:
  153. [source,console]
  154. ----
  155. PUT _cluster/settings
  156. {
  157. "persistent": {
  158. "cluster": {
  159. "remote": {
  160. "cluster_two": {
  161. "mode": null,
  162. "seeds": null,
  163. "skip_unavailable": null,
  164. "transport.compress": null
  165. }
  166. }
  167. }
  168. }
  169. }
  170. ----
  171. // TEST[continued]
  172. [[configure-remote-clusters-static]]
  173. ==== Statically configure remote clusters
  174. If you specify settings in `elasticsearch.yml`, only the nodes with
  175. those settings can connect to the remote cluster and serve remote cluster
  176. requests.
  177. NOTE: Remote cluster settings that are specified using the
  178. <<cluster-update-settings,cluster update settings API>> take precedence over
  179. settings that you specify in `elasticsearch.yml` for individual nodes.
  180. In the following example, `cluster_one`, `cluster_two`, and `cluster_three` are
  181. arbitrary cluster aliases representing the connection to each cluster. These
  182. names are subsequently used to distinguish between local and remote indices.
  183. [source,yaml]
  184. ----
  185. cluster:
  186. remote:
  187. cluster_one:
  188. seeds: 127.0.0.1:9300
  189. cluster_two:
  190. mode: sniff
  191. seeds: 127.0.0.1:9301
  192. transport.compress: true <1>
  193. skip_unavailable: true <2>
  194. cluster_three:
  195. mode: proxy
  196. proxy_address: 127.0.0.1:9302 <3>
  197. ----
  198. <1> Compression is explicitly enabled for requests to `cluster_two`.
  199. <2> Disconnected remote clusters are optional for `cluster_two`.
  200. <3> The address for the proxy endpoint used to connect to `cluster_three`.