简体   繁体   中英

Replication in Elasticsearch

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?

In Elasticsearch, the master nodes 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, eg

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM