1、集群健康状态查看
#查看集群将康状态
GET _cluster/health
{
"cluster_name": "elasticsearch",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,##集群节点数
"number_of_data_nodes": 1,##数据节点数量
"active_primary_shards": 156,##主分片数量
"active_shards": 156,##可用的分片数量
"relocating_shards": 0,##正在重新分配的分片数量,在新加或者减少节点的时候会发生
"initializing_shards": 0,##正在初始化的分片数量,新建索引或者刚启动会存在,时间很短
"unassigned_shards": 156, ##没有分配的分片,一般就是那些名存实不存的副本分片。
"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": 50
}
green 所有主要分片和复制分片都可用
yellow 所有主要分片可用,但不是所有复制分片都可用。高可用不牢靠。但不会丢失数据
red 不是所有的主要分片都可用。数据有极大风险。数据不能用
##索引级别集群状态,可以细致查看到底是哪个索引引起集群的故障的
GET _cluster/health?level=indices
##分片级别集群状态,可以细致查看到底是哪个分片引起的集群故障
GET _cluster/health?level=shards
##阻塞查看集群状态,适用于自动化脚本。当状态变为指定状态或者更好就返回继续执行。
GET _cluster/health?wait_for_status=yellow
##监控单个节点状态信息,各部分节点数据的解释请参看网址
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_monitoring_individual_nodes.html
GET _nodes/stats
##集群状态信息,比第一个更详细
GET _cluster/stats
##索引级别的统计信息,比节点级别的统计信息详细。但是并不很实用
GET my_index/_stats
GET my_index,another_index/_stats
GET _all/_stats
统计 my_index 索引。
使用逗号分隔索引名可以请求多个索引统计值。
使用特定的 _all 可以请求全部索引的统计值
##cat API 主要用于命令行下的集群、节点等信息数据查看。适用于系统运维工程师
详细使用查看网址
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_cat_api.html