小Cの已经记不起来的博客

NAS异常关机过后,导致Kibana8.2无法正常启动

NAS异常关机过后,导致Kibana无法正常启动,Kibana和需要连接elasticsearch8.2都有爆出错误

出现问题,当然就要从日志文件下手,先定位出问题可能出现在哪

Kibana 这边返回了一个比较重要的错误信息

Action failed with 'no_shard_available_action_exception: [no_shard_available_action_exception] Reason: No shard available for [get [.tasks][Pmi_cNHLSqix9Ld4IkBRjA:1817007]: routing [null]]'. Retrying attempt 1 in 2 seconds.

看起来.task索引出现了问题, 先确认下elasticsearch服务器的当前状态

请求 curl -H 'Content-type: application/json' -XGET 'http://192.168.0.1:9200/_cluster/health', 返回如下内容

{
  "cluster_name": "docker-cluster",
  "status": "red",
  "timed_out": false,
  "number_of_nodes": 1,
  "number_of_data_nodes": 1,
  "active_primary_shards": 175,
  "active_shards": 175,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 159,
  "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": 52.39520958083832
}

看得出来明显不健康, status已经为red了

继续使用 curl -s 'http://192.168.0.1:9200/_cat/shards' | grep .tasks, 发现 .task 处于 UNASSIGNED 状态

解决方案

// 重新给.task分配一个空的主分片,注意, 该索引数据会丢失!数据会丢失!数据会丢失!
// index, shard和node需要自己手动修改, 按照/_cat/shard返回的内容来就行
curl -XPOST 'http://192.168.0.1:9200/_cluster/reroute' -d '{
     "commands": [
        {
            "allocate_empty_primary": {
                "index": "'$INDEX'",
                "shard": '$SHARD',
                "node": "'$NODE'",
                "accept_data_loss": true
          }
        }
    ]
  }'

上面的URL地址需要自行修改,如果你的ES需要登录, 那么你需要使用 curl -u username:password

评论

还没有评论。

发表评论

提交后评论将经过自动审核,审核通过后公开展示。

未在播放