集群健康 (cluster health):ES集群监控信息中的一种,用status表示,status可为green,yellow,red。当status为green时,说明所有的主分片和副本分片都可用;当status为green时,说明所有的主分片都可用,但不是所有的副本分片都可用;当status为red时,说明不是所有的主分片都可用,在这种情况下,可用的主分片依然可提供搜索请求服务。
查询集群健康可使用_cat API或者_cluster API。
1、使用_cat API查询集群健康状况,如下:
GET /_cat/health?v
响应内容如下:
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1537015892 20:51:32 my-esLearn yellow 1 1 10 10 0 0 10 0 - 50.0%
从响应内容中可知,集群名为"my-esLearn",集群健康状况(status)为yellow。
将所有节点都启动之后,再次查询集群健康状况,集群健康状况(status)为green,结果如下:
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1537016682 21:04:42 my-esLearn green 3 3 29 13 1 0 0 0 - 100.0%
本例中一共三个节点,由node.total可知,一共三个节点,也可使用_cat API查询每个节点更详细的信息,如下:
GET /_cat/nodes?v
节点信息如下:
host ip heap.percent ram.percent load node.role master name
127.0.0.1 127.0.0.1 3 70 -1.00 d m node-3
127.0.0.1 127.0.0.1 7 70 -1.00 d * node-1
127.0.0.1 127.0.0.1 5 70 -1.00 d m node-2
由以上结果可知,节点名称分别为:node-1、node-2、node-3
2、使用_cluster API查询集群健康状况,如下:
GET /_cluster/health
查询结果如下:
{
"cluster_name": "my-esLearn",
"status": "green",
"timed_out": false,
"number_of_nodes": 3,
"number_of_data_nodes": 3,
"active_primary_shards": 13,
"active_shards": 29,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100.0
}
|