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:存儲大小
ip:es節點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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM