集群状态
简单的集群管理
(1)快速检查集群的健康状态
ES提供一种cat api 可以查看ES中各种各样的数据
GET /_cat/health?v
节点总数
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1512394355 21:32:35 elasticsearch yellow 1 1 1 1 0 0 1 0 - 50.0%
如何快速了解集群的监控状况?green 、yellow、red green: 每个索引的primary shard 和replica shard 都是active状态的 yellow: 每个索引的primary shard都是active状态,但部分replica shard处于非active状态(即不可用) red:不是所有索引的primary shard都是active状态,部分索引数据丢失。
我们现在就一个笔记本电脑,就启动了一个es进程,相当于就只有一个node。现在es进程中有一个index,就是kibana自己内置建立的index。 由于默认的ES配置是给每个index分配5个primary shard和5个replica shard,而且primary shard和replica shard不能在同一台机器上(为了容错)。 现在kibana自己建立的index是1个primary shard和1个replica shard。当前就一个node,所以只有1个primary shard被分配了和启动了,但是一个replica shard没有第二台机器去启动。 做一个小实验(再解压一个ES,再启动改ES):此时只要启动第二个es进程,就会在es集群中有2个node,然后那1个replica shard就会自动分配过去,然后cluster status就会变成green状态。
(2)查看集群中有哪些索引?
GET /_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open .kibana qaHIS5VeReWFG7vTLYBQbQ 1 1 1 0 3.1kb 3.1kb
(3)简单的索引操作
创建索引
PUT /test_index?pretty
查询状态
GET _cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open .kibana qaHIS5VeReWFG7vTLYBQbQ 1 1 1 0 3.1kb 3.1kb
yellow open test_index -FxZcYc9TNqYRZcYYViY6Q 5 1 0 0 650b 650b
删除索引
DELETE /test_index?pretty
查询状态
GET _cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open .kibana qaHIS5VeReWFG7vTLYBQbQ 1 1 1 0 3.1kb 3.1kb