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