记录一次elasticsearch集群 磁盘io 异常 排查

服务器执行 iotop 确认磁盘io 引发的 进程

1、sudo iotop -o

image

2、es查看当前正在执行的任务

http://10.10.0.153:9200/_cat/tasks?v&detailed=true

3、查看是否有正在迁移的任务主要看  RELOCATING

http://10.10.0.153:9200/_cat/shards?v&s=node

4、查看当前迁移的进度 

http://10.10.0.153:9200/_cat/recovery/<索引名>?v&h=index,shard,type,stage,bytes_percent,bytes,bytes_total,translog_ops_percent,time

5、排查触发自动迁移原因 

1、查看各节点磁盘的使用情况
GET /_cat/nodes?v&h=name,ip,disk.used_percent,disk.avail,disk.total

2、查看集群均衡设置

  /_cluster/settings?include_defaults=true&flat_settings=true

 6、查看该索引是否有写入操作  关注 :index_current  大于 0 有写入操作

http://10.10.0.153:9200/arn_cn_es_qk2_log_wework2026/_stats/indexing,search?pretty

7、手动停止迁移

curl -X POST "http://10.10.0.153:9200/_cluster/reroute" -u '用户名:密码'  -H 'Content-Type: application/json'   -d '{
  "commands": [
    {
      "cancel": {
        "index": "arn_cn_es_qk2_log_wework2026",
        "shard": 0,
        "node": "10.10.0.153",
        "allow_primary": true
      }
    }
  ]
}

8、优化磁盘水位线自动迁移策略

curl -X PUT "http://10.10.0.153:9200/_cluster/settings"   -u '用户名:密码'   -H 'Content-Type: application/json'   -d '{
  "persistent": {
    "cluster.routing.allocation.disk.watermark.low": "88%",
    "cluster.routing.allocation.disk.watermark.high": "92%",
    "cluster.routing.allocation.disk.watermark.flood_stage": "95%"
  }
}

9、临时降低合并开销:对于机械硬盘(HDD),可以临时将合并线程数设为1,以减轻I/O压力

curl -X PUT "http://10.10.0.153:9200/_settings"   -H "Content-Type: application/json"   -u 'elastic:changchao_!123'   -d '{
      "index.merge.scheduler.max_thread_count": 1
    }'

10、判断确认哪个线程池(search, write, merge)的队列堆积最严重 如果 rejected 计数很高,说明队列已满,开始拒绝请求

/_cat/thread_pool?v=true&h=id,name,active,queue,rejected,completed

11、分析节点热线程:找出当前最耗费资源的线程在做什么

/_nodes/hot_threads

12、检查I/O统计信息:获取详细的磁盘I/O数据  重点关注 io_stats 下的读写操作数和吞吐量。

/_nodes/stats/fs

13、检查是否有大量合并

current当前正在进行的合并数

total:累计完成合并总数

total_time:累计合并耗时

total_docs:合并中处理的文档总数

total_size合并处理的总字节数

http://10.10.0.153:9200/_nodes/stats/indices/merge

 

posted @ 2026-07-15 11:14  追梦$少年  阅读(8)  评论(0)    收藏  举报