_cat參數允許你查看集群的一些相關信息,如集群是否健康,有哪些節點,以及索引的情況等的。
檢測集群是否健康
curl localhost:9200/_cat/health?v
說明:
- curl
是一個利用URL語法在命令行下工作的文件傳輸工具
- 9200
訪問集群的端口號,可以修改。通過配置文件更改,一般不建議更改
- _cat
前綴 _ 是URL參數的一個習慣
- ?v
通過?v會顯示每一列的含義
下面的返回的響應信息:
epoch timestamp cluster status node.total node.data shards pri relo init unassign
1417844762 21:46:02 elasticsearch yellow 1 1 10 10 0 0 10
- 響應信息說明
cluster:顯示集群的名稱
status:集群的健康狀態,一般有:綠色(一切正常,集群功能健全)、黃色(所有數據可用,某些復制沒有被分配)、紅色(某些數據不可用,集群部分可用)
node.total:節點的數量
node.data:存儲數據的節點的數量
shards:分片的數量,默認情況下,每個索引會有5個分片,並進行一次復制
列出集群所有的節點
curl localhost:9200/_cat/nodes?v
響應信息
host ip heap.percent ram.percent load node.role master name
hadoop 192.168.205.134 6 69 0.01 d * Adri Nital
列出所有的索引
curl localhost:9200/_cat/indices?v
響應信息
health status index pri rep docs.count docs.deleted store.size pri.store.size
yellow open bank 5 1 947 53 423.8kb 423.8kb
yellow open test_index 5 1 3 0 9.3kb 9.3kb
查看_cat允許查看的信息
通過命令:curl localhost:9200/_cat/可以列出_cat參數允許查看的內容,下面是相應信息:
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}