日志

Elasticsearch UNASSIGNED 状态异常修复(宕机引起)

服务器宕机,导致大量分片处于UNASSIGNED状态,es 状态一直处于yellow,pod无法就绪。

检查 es 状态
curl -k -u elastic:elasticsearch123 -XGET "https://localhost:9200/_cluster/health?wait_for_status=green&timeout=5s"

为yellow则检查分片:
curl -k -u elastic:elasticsearch123 "https://localhost:9200/_cat/shards?v&pretty"

如果有大量UNASSIGNED,且数据不重要执行移除命令
curl -k -u elastic:elasticsearch123 -X PUT "https://localhost:9200/_settings" -H 'Content-Type: application/json' -d '{
  "settings": {
    "number_of_replicas": 0
  }
}'

执行后查看状态应为 green  
curl -k -u elastic:elasticsearch123 -XGET "https://localhost:9200/_cluster/health?wait_for_status=green&timeout=5s"

查看产生UNASSIGNED的原因
curl -k -u elastic:elasticsearch123 -X GET "https://localhost:9200/_cluster/allocation/explain?pretty"

分片异常可能为引起以下报错
failed to retrieve password hash for reserved user


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注