简单集群操作
查看节点信息
GET /?pretty
//result
{
"name": "sqmcQNC", //节点名
"cluster_name": "elasticsearch", //集群名
"cluster_uuid": "Xar4EVm2QaW92vWL0tj5AA",
"version": {
"number": "5.5.0",
"build_hash": "260387d",
"build_date": "2017-06-30T23:16:05.735Z",
"build_snapshot": false,
"lucene_version": "6.6.0"
},
"tagline": "You Know, for Search"
}
检查集群健康状况
GET /_cluster/health
//result
{
"cluster_name": "elasticsearch",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 6,
"active_shards": 6,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 6,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 50
}
GET /_cat/health?v
//result
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1500427656 09:27:36 elasticsearch yellow 1 1 1 1 0 0 1 0 - 50.0%
status表示集群的健康状态:
green:每个索引的primary shard和replica shard都是active状态的
yellow:每个索引的primary shard都处于active状态,但是部分replica shard不是active状态,处于不可用状态
red:不是所有索引的primary shard都处于active状态,部分索引有数据丢失
目前处于yellow状态是因为我们现在就启动了一个es进程,相当于就只有一个node。现在es中有一个index,就是kibana自己内置建立的index。由于默认的配置是给每个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没有第二台机器去启动。
快速获取集群中有那些索引
GET /_cat/indices?v
//result
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open .kibana 1YPy2F8hQ9ymtYh3XbEhQQ 1 1 1 0 3.2kb 3.2kb