0

I have created a cluster with one master node and two data nodes. I need to know how replicas are created once I index a document in master node. Is there a way to find out if my replicas are successfully created or not? Also, how do I shut down my master node and check if my replicas are accessible through my data node?

1 Answer 1

3

In Elasticsearch, the nodes having only the master role don't hold any data at all. It is not the same concept as in a master/slave database. In ES, you cannot shutdown the master and expect the data node to work. If you shut down your single master node, your cluster goes red and nothing works anymore.

Primary and replica shards are all stored on the data nodes only. Your indexes are partitioned into primary shards which will be balanced over all data nodes of your cluster. If you decide to have replica shards, the primary shards will be copied and balanced over the data nodes the same way.

When you index a document, you typically send it to the data nodes, the document will be indexed in the primary shard and then replicated into the corresponding replica shard.

Once you have indexed a document you can check whether both the primary and replica shards contain that document using the preference parameter in your search, e.g.

This will only search the primary shards

GET my-index/_search?preference=_primary

This will only search the replica shards

GET my-index/_search?preference=_replica

If the indexing operation was successful, both searches should return exactly the same results.

Note that the preference parameter has been deprecated in 6.1 and will be removed in 7 as its usage is discouraged.

Sign up to request clarification or add additional context in comments.

4 Comments

Very very late response, Your answer is partially true. It holds true when there is a dedicated master node and two dedicated data nodes. But this won't be a case when the master node is made eligible to hold data in "elasticsearch.yml" file. Also, when the master node goes down, election takes place among the rest of the nodes( i.e., data nodes) to choose the master which is one of the advantages of using distributed network.
Well, if your nodes have both roles (master and data) then of course you can bring down the master and a new one will be elected and a master node can also hold data if it has the data role. That doesn't change my answer, though. Anything else you need?
@val Your answer may need slight correction as it states in first sentence "the master nodes don't hold any data at all" - which is not always true and may be misleading. See node roles explained elastic.co/guide/en/elasticsearch/reference/current/…
@lubosdz you're right. I'll correct that to make sure there's no ambiguity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.