Search code examples
dockerelasticsearchcluster-computingdocker-container

Is there a way to deploy different Elasticsearch clusters in one host to demonstrate Cross Cluster Search?


I have 3 different Elasticsearch containers (which I deploy by the next command run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.9.2)

I want to use them as 3 clusters with 1 node in every cluster. after that I defined 2 of them as a remote clusters for one cluster (port 9200 is the "master" and 9201 9202 is the remote). to define it I use:

cluster:
    remote:
        cluster_one: 
            seeds: 127.0.0.1:9201
        cluster_two: 
            seeds: 127.0.0.1:9202

and I try to run the search

GET /cluster_one:twitter/_search
{
  "query": {
    "match": {
      "user": "kimchy"
    }
  }
}

but it didn't work, I assume it related to the way I defined the clusters but I didn't find what I do wrong.


Solution

  • The documentation tells us that :

    Cross-cluster search and cross-cluster replication require the remote_cluster_client role.
    

    Moreover, the remote cluster page tells us that

    role: By default, any non-master-eligible node can act as a gateway node. Dedicated master nodes are never selected as gateway nodes.
    

    Since all nodes have the roles master & data by default, no node can act as a gateway node and cross-cluster operations cannot work.

    I got one working there.

    The static remote cluster definition needs to be done on every node in following clusters using either env variables (as I did in the provided example) or elasticsearch.yml.

    The url you need to match against is the url to the docker service hosting the gateway node.

    The port needs to match the remote node's transport port.