ES---underlying principle

ES—underlying principle

ES is generally divided into: main node, child node, cloud node

Master node : (master: for example, the boss below) is responsible for creating indexes, deleting indexes, assigning shards, tracking the status of nodes in the cluster, etc.

Child nodes : responsible for storing data, modifying indexes, querying information, etc.

Cloud node : Responsible for recovery when data is lost

Index sharding

Insert picture description here
Each index has 5 shards by default, 1 number of replicas
number_of_shards: number of shards
number_of_replicas: number of backups
Insert picture description here
[Note: This picture is a screenshot of the ES head plug-in when creating an index]

As for how to store files to different nodes, es will allocate according to the number of hashcode (routing)% fragments. The
Insert picture description here
thicker color—>the ​​main fragment and the
lighter color—>backup fragment.

When modifying, modify the backup shard first. After the master node confirms that the modification is correct, the content of the backup shard will be copied to the primary shard. If the modification fails, the primary shard can restore the backup shard. However, it is generally not recommended to modify ES, because ES itself is used for query and storage, and it will be more troublesome to modify

When querying information , first the master sends a message to the node that contains the primary shard (generally, the master only contains the primary shard, but not all of them can be placed on the primary node because of load balancing). I want to query certain information, corresponding The node starts to query,If the corresponding node is down, The master will query the nodes that have backup information, and promote the backup shard to be the primary shard, and notify other surviving and idle nodes to backup information to form a backup shard.If the query speed of the primary shard is too slow, And there is an idle node with backup shards, then this idle node will be requested to query at the same time.

Write so much first,

Guess you like

Origin blog.csdn.net/qq_43288259/article/details/114920669