Elasticsearch Authoritative Guide--cluster

Source: Internet
Author: User


1. An empty cluster

If you start a single elasticsearch instance, there is no data and index. Then the cluster is in the following form:


650) this.width=650; "src=" Https://www.elastic.co/guide/en/elasticsearch/guide/current/images/elas_0201.png "alt= "A cluster with one empty node"/>


node, which is a running Elasticsearch instance. A cluster cluster contains one or more nodes with the same cluster.name. Cluster.name is specified in the ELASTICSEARCH.YML. The nodes in a cluster share the data and pressure of the entire cluster. When nodes are added to or removed from the cluster, the cluster itself distributes the data from the new evenly to the other nodes.

When the master node in the cluster is elected, the master node is responsible for changes at the entire cluster level, such as creating or deleting an index, or adding or removing a node. The master node does not involve changes or queries at the document level, which means that when traffic grows, there is only one master node in the cluster that does not become a bottleneck. Any node can be a master node.

Users can communicate with any node in the cluster, including the master node. Each node knows where each document resides and forwards our query requests directly to the node where the data is stored. The node then returns the response directly to the client. All of this is managed by Elasticsearch itself.



2. Cluster health status

Curl Http://127.0.0.1:9200/_cluster/health?pretty
{"Cluster_Name": "Xxxxx_prod_elasticsearch", "status": "Green", "timed_out": false, "number_of_nodes": 1, "Numbe  R_of_data_nodes ": 1," Active_primary_shards ": 0," Active_shards ": 0," Relocating_shards ": 0," Initializing_shards " : 0, "Unassigned_shards": 0, "Delayed_unassigned_shards": 0, "Number_of_pending_tasks": 0, "Number_of_in_flight_fe Tch ": 0," Task_max_waiting_in_queue_millis ": 0," Active_shards_percent_as_number ": 100.0}



The most important is the Status field, which indicates the monitoring status of the entire cluster.

Green represents all the primary and Repica shard activity states.

Yellow indicates that all primary shards are active, but not all replica shards are active

Red is not all primary shards are active


3. Add an Index

In order to add data to the Elasticsearch, we need an index, which is where the data is stored. In fact, an index is just a logical domain namespace that points to one or more physical shards.

A shard is just one slice of all the data in the index, and it is a low-level unit of work. The document is stored and indexed in the Shard, but the application does not communicate directly with the Shard, but rather through the index.

A shard is either a primary shard or a replica shard. Each document in the index is owned by a single primary shard. Therefore, the number of primary shards determines the maximum data capacity that the index can store.

The replica shard is only a copy of the primary shard to provide redundancy for the data, preventing data loss when the hardware fails. and provides the ability to query documents or get documents.

Now create an index called blogs.

Curl-xput Http://127.0.0.1:9200/blogs
curl -xget  http://127.0.0.1:9200/blogs?pretty=true 
{   "blogs"  : {     "aliases"  : { },     "Mappings"  : { },     " Settings " : {      " index " : {          "Creation_date"  :  "1461250293462",         "Number_of_shards"  :  "5",         "Number_of_replicas"  :   "1",         "uuid"  :  "FIDJCVOXTQY9EMAKMIRNRQ",          "Version"  : {            "created"  :  "2030199"         }       }    },     "warmers"  : { }   }} 


By default, the newly created index is assigned 5 primary shards, and each primary shard is assigned 1 replica shards.


650) this.width=650; "src=" Https://www.elastic.co/guide/en/elasticsearch/guide/current/images/elas_0202.png "alt= "A Single-node cluster with an index"/>

Then view the status of the cluster

Curl-xget Http://127.0.0.1:9200/_cluster/health?pretty
{"Cluster_Name": "Xxxx_prod_elasticsearch", "status": "Yellow", "timed_out": false, "number_of_nodes": 1, "Numbe  R_of_data_nodes ": 1," Active_primary_shards ": 5," Active_shards ": 5," Relocating_shards ": 0," Initializing_shards " : 0, "Unassigned_shards": 5, "Delayed_unassigned_shards": 0, "Number_of_pending_tasks": 0, "Number_of_in_flight_fe Tch ": 0," Task_max_waiting_in_queue_millis ": 0," Active_shards_percent_as_number ": 50.0}


You can see that status is yellow State, Unassigned_shards is 5

The cluster health state is yellow that all primary shards are active and can provide any request to the outside, but not all replica shards are active.


4. Add an alternate node

Running only a single node means there is a single point of failure and there is no redundant functionality. We can protect our data by adding a backup node.






Reference Documentation:

Https://www.elastic.co/guide/en/elasticsearch/guide/current/distributed-cluster.html


This article is from the Linux SA John blog, so be sure to keep this source http://john88wang.blog.51cto.com/2165294/1766432

Elasticsearch Authoritative Guide--cluster

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.