Reputation: 551
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?
Upvotes: 0
Views: 1253
Reputation: 217304
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.
Upvotes: 3