- ElasticSearch Cookbook
- Alberto Paro
- 474字
- 2021-04-02 10:09:55
Understanding cluster, replication, and sharding
Related to shard management, there is the key concept of replication and cluster status.
Getting ready
You need one or more nodes running to have a cluster. To test an effective cluster you need at least two nodes (they can be on the same machine).
How it works...
An index can have one or more replicas—the shards are called primary if they are part of the master index and secondary if they are part of replicas.
To maintain consistency in write operations the following workflow is executed:
- The write is first executed in the primary shard.
- If the primary write is successfully done, it is propagated simultaneously in all the secondary shards.
- If a primary shard dies, a secondary one is elected as primary (if available) and the flow is re-executed.
During search operations, a valid set of shards is chosen randomly between primary and secondary to improve performances.
The following figure shows an example of possible shards configuration:

There's more…
Related to the concept of replication there is the cluster indicator of the health of your cluster.
It can cover three different states:
- Green: Everything is ok.
- Yellow: Something is missing but you can work.
- Red: "Houston, we have a problem". Some primary shards are missing.
Mainly yellow status is due to some shards that are not allocated. If your cluster is in recovery status, just wait if there is enough space in nodes for your shards.
If your cluster, even after recovery is still in yellow state, it means you don't have enough nodes to contain your replicas so you can either reduce the number of your replicas or add the required number of nodes.
When you have lost data (that is, one or more shard is missing), you need to try restoring the node(s) that are missing. If your nodes restart and the system goes back to yellow or green status you are safe. Otherwise, you have lost data and your cluster is not usable. In this case, delete the index/indices and restore them from backup (if you have it) or from other sources.
See also
- Replica and shard management in this chapter.
- 全屋互聯(lián):智能家居系統(tǒng)開發(fā)指南
- Red Hat Enterprise Linux 8系統(tǒng)管理實戰(zhàn)
- Linux從零開始學(視頻教學版)
- 開源安全運維平臺OSSIM疑難解析:入門篇
- Ubuntu Linux操作系統(tǒng)
- Windows Phone應(yīng)用程序開發(fā)
- 高性能Linux服務(wù)器構(gòu)建實戰(zhàn):系統(tǒng)安全、故障排查、自動化運維與集群架構(gòu)
- 操作系統(tǒng)分析
- Hands-On UX Design for Developers
- iOS 8開發(fā)指南
- Agile IT Security Implementation Methodology
- CSS揭秘
- Learn OpenShift
- 鴻蒙HarmonyOS應(yīng)用開發(fā)從入門到精通
- Getting Started with Citrix XenApp 6.5