ElasticSearch---查询es集群状态、分片、索引

查看es集群状态:

curl -XGET http://localhost:9200/_cat/health?v

如果?后面加上pretty,能让返回的json格式化。
加上?v的返回结果,如下:

epoch      timestamp cluster  status node.total node.data   shards   pri    relo init unassign pending_tasks max_task_wait_time active_shards_percent
1622993577 23:32:57  test      green      100        97     39252   19619    0    0        0             0                  -                100.0%

解释如下:

cluster ,集群名称
status,集群状态 green代表健康;yellow代表分配了所有主分片,但至少缺少一个副本,此时集群数据仍旧完整;red代表部分主分片不可用,可能已经丢失数据。
node.total,代表在线的节点总数量
node.data,代表在线的数据节点的数量
shards, active_shards 存活的分片数量
pri,active_primary_shards 存活的主分片数量 正常情况下 shards的数量是pri的两倍。
relo, relocating_shards 迁移中的分片数量,正常情况为 0
init, initializing_shards 初始化中的分片数量 正常情况为 0
unassign, unassigned_shards 未分配的分片 正常情况为 0
pending_tasks,准备中的任务,任务指迁移分片等 正常情况为 0
max_task_wait_time,任务最长等待时间
active_shards_percent,正常分片百分比 正常情况为 100%

查看es分片信息:

  • 查看es分片信息,模糊匹配,比如匹配test:
curl -XGET http://localhost:9200/_cat/shards/test*?v

返回信息如下:

index              shard prirep   state       docs   store   ip              node
index_test~2021-06  5     r      STARTED       12  134.8kb   88.888.888.888  88.888.888.888:9301

解析如下:

index:所有名称
shard:分片数
prirep:分片类型,p=pri=primary为主分片,r=rep=replicas为复制分片
state:分片状态,STARTED为正常分片,INITIALIZING为异常分片
docs:记录数
store:存储大小
ipes节点ip
node:es节点名称
  • 查看状态为unassigned的es分片信息:
curl -XGET http://localhost:9200/_cat/shards | grep UNASSIGNED

查看es索引

  • 查看es所有索引:
    indices表示索引,是index的复数.
curl -XGET http://localhost:9200/_cat/indices?pretty

返回结果示例如下:

health status index                   uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   index_test~2021-06     6rb1BsHpSA-pHT7u_3UNWA  20   1        208            0      1.1mb        609.8kb
green  open   index_test~2021-07     smyDnnX3QB-4N81p4Wq9fA  30   1          4            1    222.4kb        111.2kb

返回的结果解析如下:

health:  green代表健康;yellow代表分配了所有主分片,但至少缺少一个副本,此时集群数据仍旧完整;red代表部分主分片不可用,可能已经丢失数据。
pri:primary缩写,主分片数量
rep:副分片数量
docs.count: Lucene 级别的文档数量
docs.deleted: 删除的文档
store.size:全部分片大小(包含副本)
pri.store.size:主分片大小
  • 查看索引,模糊匹配,比如匹配test:
curl -XGET http://localhost:9200/_cat/indices/test_*?v

参考资料:

https://blog.csdn.net/weixin_44723434/article/details/90452083
https://blog.csdn.net/lizz861109/article/details/115668177

posted on   乐之者v  阅读(17419)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2016-06-06 Android笔记:ContextMenu
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示