es查看集群信息命令_cat和_cluster

有kibana最好了。
https://www.elastic.co/guide/en/elasticsearch/reference/current/cat.html 感兴趣的,英语OK的同学可以去官网自查
·························································
查看API
查看别名接口(_cat/aliases): 查看索引别名
查看分配资源接口(_cat/allocation)
查看文档个数接口(_cat/count)
查看字段分配情况接口(_cat/fielddata)
查看健康状态接口(_cat/health)
查看索引信息接口(_cat/indices)
查看master信息接口(_cat/master)
查看nodes信息接口(_cat/nodes)
查看正在挂起的任务接口(_cat/pending_tasks)
查看插件接口(_cat/plugins)
查看修复状态接口(_cat/recovery)
查看线城池接口(_cat/thread_pool)
查看分片信息接口(_cat/shards)
查看lucence的段信息接口(_cat/segments)

··························································································
集群API
查看集群健康状态接口(_cluster/health)
查看集群状况接口(_cluster/state)
查看集群统计信息接口(_cluster/stats)
查看集群挂起的任务接口(_cluster/pending_tasks)
集群重新路由操作(_cluster/reroute)
更新集群设置(_cluster/settings)
节点状态(_nodes/stats)
节点信息(_nodes)
节点的热线程(_nodes/hot_threads)
关闭节点(\nodes/_master/_shutdown)

以下对常用的命令做了解释·············································································

verbose
每个命令都支持使用?v参数,来显示详细的信息

help
每个命令都支持使用help参数,来输出可以显示的列:
$ curl localhost:9200/_cat/master?help
id | | node id
host | h | host name
ip | | ip address
node | n | node name

headers
通过h参数,可以指定输出的字段:
$ curl localhost:9200/_cat/master?v
id host ip node
QG6QrX32QSi8C3-xQmrSoA 127.0.0.1 127.0.0.1 Manslaughter

$ curl localhost:9200/_cat/master?h=host,ip,node
127.0.0.1 127.0.0.1 Manslaughter

参数拼到?后面 和 get请求一样
····································································································
1._cat/allocation 查看分配资源接口

curl 192.168.10.7:9200/_cat/allocation
9 38.8mb 4.7gb 13gb 17.7gb 26 192.168.2.116 192.168.2.116 node-1
9 38.8mb 9.1gb 8.6gb 17.7gb 51 192.168.2.114 192.168.2.114 node-2

curl 192.168.10.7:9200/_cat/allocation?v ?v表示显示详细信息(字段名)
shards disk.indices disk.used disk.avail disk.total disk.percent host ip node
9 38.8mb 9.1gb 8.6gb 17.7gb 51 192.168.2.114 192.168.2.114 node-1
9 38.8mb 4.7gb 13gb 17.7gb 26 192.168.2.116 192.168.2.116 node-2

shards:分片个数
disk.indices:索引所占磁盘大小
disk.used:已用磁盘大小
disk.avail:可以使用磁盘大小
disk.total:磁盘总容量
disk.percent:磁盘使用百分比
host:主机名
ip:服务ip
node:节点名称
------------------------------------------------------------
2._cat/nodes?v

curl 192.168.10.7:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.2.114 10 96 1 0.00 0.01 0.00 mdi - node-1
192.168.2.116 3 100 0 0.00 0.00 0.00 mdi * node-2

heap.percent:堆内存占的内存百分比
ram.percent:物理内存占用百分比
cpu:表示使用的cpu核心
load_1m load_5m load_15m:1分钟 5分钟 15分钟 占用系统cup百分比
node.role:表示节点能充当的角色主、数据 节点
master:表示当前是否为主节点,*表示当前为主
------------------------------------------------------------
3._cluster/health 快速检查集群的健康状况

curl localhost:9200/_cluster/health?pretty # ?pretty JSON格式显示,易读
{
"cluster_name" : "RK",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 2,
"active_primary_shards" : 9,
"active_shards" : 18,
"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
}

输出里最重要的就是 status 这行。很多开源的 ES 监控脚本,其实就是拿这行数据做报警判断。status 有三个可能的值:
green 绿灯,所有分片都正确运行,集群非常健康。
yellow 黄灯,所有主分片都正确运行,但是有副本分片缺失。这种情况意味着 ES 当前还是正常运行的,但是有一定风险。注意,在 Kibana4 的 server 端启动逻辑中,即使是黄灯状态,Kibana 4 也会拒绝启动,死循环等待集群状态变成绿灯后才能继续运行。
red 红灯,有主分片缺失。这部分数据完全不可用。而考虑到 ES 在写入端是简单的取余算法,轮到这个分片上的数据也会持续写入报错。


curl 'localhost:9200/_cluster/health?level=cluster&pretty'
接口请求的时候,可以附加一个 level 参数,指定输出信息以 indices 还是 shards 级别显示。当然,有三个级别:cluster,indices,shards (如果写错了就默认输出cluster级别)一般来说,indices 级别就够了。

猜你喜欢

转载自www.cnblogs.com/timor19/p/12810535.html