remote-clusters-connect.asciidoc 8.0 KB

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