Elasticsearch-cluster principle, elasticsearch-Cluster

Source: Internet
Author: User

Elasticsearch-cluster principle, elasticsearch-Cluster


Elasticsearch version: 6.0

I. ES Clusters

It is composed of one or more nodes with the same cluster. name to jointly bear the pressure on data and load.

The elected master node will be responsible for management.Cluster rangeAll changes, such as adding/deleting indexes and adding/deleting nodes, are not involved.Document LevelChange and search operations.

Requests can be sent to any node in the cluster. Each node knows the location of any document and forwards the requests directly to the node that stores the documents we need, it collects data from the nodes that contain the documents we need and returns the final result to the client.

Ii. ES sharding

The indexes used to add data to elasticsearch actually point to the logical namespace of one or more physical shards.

A shard is an underlying unit of work that stores part of the data. A shard is a Lucene instance.

Any document in the index belongs to onePrimary shardTherefore, the number of primary shards determines the maximum data size that the index can store.

A replica Shard is a copy of the primary shard. It serves as a redundant backup to protect data from loss and provides services for reading operations such as searching and returning documents.

The number of primary shards is determined when the index is created, but the replica shards can be modified at any time,

How to Create a shard: (the index name is test. Three primary shards and one replica shard are allocated. Each primary Shard has one replica shard)

PUT/test

{

"Settings ":{

"Number_of_shards": 3,

"Number_of_replicas": 1

}

}

Iii. standalone Environment

At this time, the ES Health status field is yellow because the copy is not allocated to any node.

Iv. Horizontal resizing

1. Start the second node, as long as the cluster. if the name is the same as that of the first node, the cluster is automatically found and added. For different machines, you need to configure a list of connectable unicast hosts.

At this time, the three replicas are allocated to node2. all indexed documents are stored in the primary shard and copied to the corresponding replica shard in parallel, make sure that you can obtain documents from both the primary and replica shards.

2. Automatic third node, the cluster will re-allocate the parts to distribute the load. (Up to 6 nodes can be enabled)

The number of replica shards can be dynamically adjusted on the running cluster.

Increase the number of parts to 2.

PUT /blogs/_settings
{
   "number_of_replicas" : 2
}
The cluster shard status is as follows:

V. node faults

When the master node is disabled, the cluster will first elect a new master node. Then, the new master node immediately promotes the replica shards corresponding to NODE2 and NODE3 to the master partition. At this time, the cluster status changes to yellow.

Restart the master node, and the cluster can re-allocate the copies. If NODE1 still has the previous parts, it will try to reuse them and copy the modified data files only from the master part.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.