Elasticsearch的集群监控工信息中包含了许多的统计数据,其中最为重要的一项就是集群健康,他在status 字段中展示为green、yellow或者red。

    1. GET /_cluster/health

    在一个不包含任何索引的空集群中,他将会有一个类似于如下所示的返回内容:

    {
       "cluster_name":          "elasticsearch",
       "status":                "green", 
       "timed_out":             false,
       "number_of_nodes":       1,
       "number_of_data_nodes":  1,
       "active_primary_shards": 0,
       "active_shards":         0,
       "relocating_shards":     0,
       "initializing_shards":   0,
       "unassigned_shards":     0
    }
    

    status字段指示着当前集群在总体上是否工作正常。他的三种颜色含义如下:

    1. green:所有的主分片和副本分片都正常运行
    2. yellow:所有的主分片都正常运行,但不是所有的副本分片都正常运行
    3. red:有主分片没有正常运行。

    在本章节剩余的部分,我们将解释什么是主分片和副本分片,以及上面提到的这些颜色的实际意义。