今天突然收到es集群告警,健康状态为red。
查看集群索引分片,的确有3个异常。
我们也可以通过命令查找是否有异常的分片和索引。
curl -s http://127.0.0.1:9200/_cat/shards/ | grep UNASSIGNED curl http://127.0.0.1:920/_cat/shards/index_name
然后可以通过命令查看具体的错误信息
curl http://127.0.0.1:9200/_cluster/allocation/explain
如果有插件的,也可以通过插件查看未分配原因
报错详情:
"details": "failed shard on node [xxx]: failed to create shard, failure IOException[failed to obtain in-memory shard lock]; nested: ShardLockObtainFailedException[[article][5]: obtaining shard lock timed out after 5000ms, previous lock details: [shard creation] trying to lock for [shard creation]]; ",
命令输出的是json格式,自己找个工具美化一下。
可以看到尝试分配了5次,都失败了,没有可分配的节点。
继续往后面看,提示让我手动执行重试操作
于是马上执行命令手动重试
curl -XPOST http://127.0.0.1:9200/_cluster/reroute?retry_failed=true
再去看状态已经变成yellow,已经开始在分配了
curl http://127.0.0.1:9200/_cluster/health?pretty