API並非DSL語句
1、健康檢查命令
curl -X GET "localhost:9200/_cat/health?v&pretty"
執行以上命令或者直接在瀏覽器輸入以上鍊接,將會得到如下返回包含集羣名稱,健康狀態分片信息等狀態。
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1590149221 12:07:01 log-collection yellow 1 1 169 169 0 0 166 0 - 50.4%
我們可以看到status
狀態爲yellow
黃色,即可用狀態,
集羣健康狀態可以分爲以下三種
green
(綠色):完全健康yellow
(黃色):所有數據節點可用,但是某些副本不可用,或者沒有配置副本red
(紅色):某些數據節點不可用。
當集羣狀態爲紅色的時候仍然部分可用,但是需要儘快進行修復
2、我們可以通過以下命令查看節點信息
curl -X GET "localhost:9200/_cat/nodes?v&pretty"
得到如下返回,記錄了節點名稱是否主節點,性能情況的星系
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.0.20 83 94 5 1.07 0.60 0.42 dilm * node-1
3、列出所有索引命令
curl -X GET "localhost:9200/_cat/indices?v&pretty"
將得到如下返回
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open log-nginx-2-access-2020-05-12 A1FXDbIwSjeDzvbfXZgUFA 1 1 16230 0 2.7mb 2.7mb
4、創建索引
curl -X PUT "localhost:9200/customer?pretty"
返回執行成功
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "customer"
}
然後可以通過上一個命令查看索引。
5、刪除索引
curl -X DELETE "localhost:9200/customer?pretty"
返回
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size