Elasticsearch 常用运维命令(持续更新)
程序员文章站
2022-07-06 10:51:01
...
- 查看所有分片状态
GET /_cat/shards
- 查看指定索引的分片状态
GET /_cat/shards?index=***
- 对集群中分配失败的索引进行重新分配
POST /_cluster/reroute?retry_failed=true
- 查看集群状态
GET /_cluster/health
执行结果为:
{
"cluster_name" : "docker-cluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 637,
"active_shards" : 637,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 97,
"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" : 86.78474114441417
}
- 查看索引级状态
GET /_cluster/health?level=indices
- 查看分片级状态
GET /_cluster/health?level=shards
- 查看索引分片分配异常原因
GET _cluster/allocation/explain
执行结果为:
{
"index" : "plume_log_run_20200922",
"shard" : 0,
"primary" : false,
"current_state" : "unassigned",
"unassigned_info" : {
"reason" : "CLUSTER_RECOVERED",
"at" : "2020-10-26T04:34:49.042Z",
"last_allocation_status" : "no_attempt"
},
"can_allocate" : "no",
"allocate_explanation" : "cannot allocate because allocation is not permitted to any of the nodes",
"node_allocation_decisions" : [
{
"node_id" : "rUDBHtUIRZqE3NPPBZ1NRw",
"node_name" : "es",
"transport_address" : "172.31.0.2:9300",
"node_attributes" : {
"ml.machine_memory" : "25111240704",
"xpack.installed" : "true",
"transform.node" : "true",
"ml.max_open_jobs" : "20"
},
"node_decision" : "no",
"deciders" : [
{
"decider" : "same_shard",
"decision" : "NO",
"explanation" : "the shard cannot be allocated to the same node on which a copy of the shard already exists [[plume_log_run_20200922][0], node[rUDBHtUIRZqE3NPPBZ1NRw], [P], s[STARTED], a[id=eYEZ-ftURmeb7uunPeqpcg]]"
}
]
}
]
}