To guarantee data security, Alibaba Cloud Elasticsearch instances are isolated from each other by default. If you want to search data across two Elasticsearch instances, you must interconnect the Elasticsearch instances.

Prerequisites

Before you interconnect two Elasticsearch instances, make sure that the following requirements are met:
  • Both instances are using the same Elasticsearch version.
  • Both instances are created by the same user account.
  • Both instances are deployed in the same VPC network.
  • Both instances are deployed in one zone or deployed across multiple zones.

Background information

After the preceding requirements are met, log on to the Elasticsearch console and go to the Instance Interconnection page to configure the corresponding settings. For more information, see Configure instance interconnection.

Configure instance interconnection

  1. Go to the Security page in the Elasticsearch console.
  2. Click Edit on the right side of Instance Interconnection.
  3. In the Edit Configuration dialog box, click Add Instance.Configure instance interconnection
  4. In the Add Instance dialog box, select the ID of the instance to which you need to connect the current instance, and click OK.Add Instance page
    Notice
    • If you are using a RAM user account, the RAM user account must have the List permission to obtain all instances under the corresponding Alibaba Cloud account.
    • After the prerequisites are met, you can select one or more instances in the Add Instance dialog box.
    • After you connect Instance A to Instance B, you can find the ID of Instance A on the Instance Interconnection page of Instance B. This means that the communication between Instance A and Instance B is bidirectional.
    After you add an instance, you can find the added instance in the Interconnected Instances list in the Edit Configuration dialog box.Interconnected instance list

Remove an interconnected instance

  1. Go to the Security page in the Elasticsearch console.
  2. Click Edit on the right side of Instance Interconnection.
  3. In the Edit Configuration dialog box, click Remove in the Actions column of the Interconnected Instances list.Remove an interconnected instance
  4. In the Remove Instance message, click OK to disconnect the instance.
    After you click OK, the instance is removed from the Interconnected Instances list in the Edit Configuration dialog box.

Query interconnected instances

  1. Go to the Security page in the Elasticsearch console.
  2. Click Edit on the right side of Instance Interconnection.
  3. You can view the interconnected instances in the Interconnected Instances list in the Edit Configuration dialog box.Query interconnected instances
    Notice When you delete an instance that is interconnected to another instance, the The instance is already connected to an instance. If you delete the instance, the interconnection is removed. Are you sure you want to delete the instance? message is displayed for you to confirm the operation.

Configure cross-cluster search

  1. Log on to the Kibana console of the Elasticsearch instance that is interconnected to the current instance.
  2. Send the following request to create an index and add a document to the index.
    PUT /twitter
    {
        "settings" : {
            "index" : {
                "number_of_shards" : 3, 
                "number_of_replicas" : 2 
            }
        }
    }
    POST twitter/doc/
    {
        "user" : "kimchy",
        "post_date" : "2009-11-15T14:12:12",
        "message" : "trying out Elasticsearch"
    }
    Note The index and document are used to test the cross-cluster search feature later.
  3. Log on to the Kibana console of the current Elasticsearch instance.
  4. Use one of the following methods to configure cross-cluster search on the current Elasticsearch instance.
    In the following methods, Elasticsearch V6.7 is used. The methods used to configure cross-cluster search in other Elasticsearch versions are similar. For more information, see Configure cross-cluster search in Elasticsearch V6.7, Configure cross-cluster search in Elasticsearch V6.3, and Configure cross-cluster search in Elasticsearch V5.5.
    • Method 1: configure cross-cluster search by using the internal network endpoint of the remote Elasticsearch instance.
      PUT _cluster/settings
      {
        "persistent": {
          "cluster": {
            "remote": {
              "cluster_one": {
                "seeds": [
                  "es-cn-o4xxxxxxxxxxxx4f1.elasticsearch.aliyuncs.com:9300"
                ]
              }
            }
          }
        }
      }
    • Method 2: configure cross-cluster search by using the IP addresses of the nodes in the remote Elasticsearch instance.
      PUT _cluster/settings
      {
        "persistent": {
          "cluster": {
            "remote": {
              "cluster_one": {
                "seeds": [
                  "10.8.xx.xx:9300",
                  "10.8.xx.xx:9300",
                  "10.8.xx.xx:9300"
                ]
              }
            }
          }
        }
      }
    Notice
    • If the current instance is deployed in one zone, you can use method 1 or method 2 to configure cross-cluster search. More than one instance can be connected to the current instance.
    • If the current instance is deployed across multiple zones, you can only use method 2 to configure cross-cluster search. More than one instance can be connected to the current instance.
    • If you log on to Instance A and specify Instance B as the remote instance, you can search indexes on Instance B from Instance A. However, you cannot search indexes on Instance A from Instance B. To search indexes on Instance A from Instance B, you must log on to Instance B and specify the endpoint or node IP addresses of Instance A.
  5. Send the following request to verify that the cross-cluster search feature runs normally.
    POST /cluster_one:twitter/doc/_search
    {
      "query": {
        "match_all": {}
      }
    }
    If the cross-cluster search feature runs normally, the following result is returned.
    {
      "took" : 78,
      "timed_out" : false,
      "_shards" : {
        "total" : 3,
        "successful" : 3,
        "skipped" : 0,
        "failed" : 0
      },
      "_clusters" : {
        "total" : 1,
        "successful" : 1,
        "skipped" : 0
      },
      "hits" : {
        "total" : 1,
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "cluster_one:twitter",
            "_type" : "doc",
            "_id" : "qudxxxxxxxxxx_7ie6J",
            "_score" : 1.0,
            "_source" : {
              "user" : "kimchy",
              "post_date" : "2009-11-15T14:12:12",
              "message" : "trying out Elasticsearch"
            }
          }
        ]
      }
    }