ElasticSearch 排障常用方法

文章目录

1,集群状态,节点在线情况,集群参数配置

bash 复制代码
GET _cluster/health?pretty
# {
#   "cluster_name" : "my-es",
#   "status" : "green",
#   "timed_out" : false,
#   "number_of_nodes" : 3,
#   "number_of_data_nodes" : 3,
#   "active_primary_shards" : 917,
#   "active_shards" : 1834,
#   "relocating_shards" : 0,
#   "initializing_shards" : 0,
#   "unassigned_shards" : 0,
#   "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" : 100.0
# }

# 查看帮助:GET _cat/nodes?help
GET _cat/nodes?v
GET _cat/nodes?v&h=ip,name,version,disk.used_percent,ram.percent,cpu,file_desc.current,file_desc.max   
# ip           name                version disk.used_percent ram.percent cpu file_desc.current file_desc.max
# 192.56.0.108 master-192.56.0.108 7.5.1               38.64          98   8             10894         65535
# 192.56.0.107 master-192.56.0.107 7.5.1               38.64          98   6             10895         65535
# 192.56.0.106 master-192.56.0.106 7.5.1               38.87          99   5             10998         65535
GET _nodes/stats/process?filter_path=**.max_file_descriptors
# {
#   "nodes" : {
#     "nXQsMpumSsC5zT818W7c4A" : {
#       "process" : {
#         "max_file_descriptors" : 65535
#       }
#     },
# ...
# }



#查看集群配置参数
GET _cluster/settings?include_defaults=true&pretty
GET _cluster/settings?pretty
# {
#   "persistent" : {
#     "cluster" : {
#       "max_shards_per_node" : "10000"
#     },
#     "search" : {
#       "max_buckets" : "100000"
#     }
#   },
#   "transient" : { }
# }

2,查看异常索引、分片,分析异常原因,手动分配分片

  • 可能的问题: 查看集群状态,提示unassigned_shards 很多
  • 在kibana 可查看到某些索引状态为red
bash 复制代码
# 查看帮助:GET _cat/indices?help
#GET _cat/indices?v
# 查看所有异常索引
GET _cat/indices?health=red

GET _cat/shards?v
GET _cat/shards?v&h=index,shard,state,unassigned.reason
GET _cat/shards/linux_2023_11?v
# index             shard prirep state        docs   store ip           node
# linux_2023_11 5     p      STARTED 867480195 228.1gb 192.56.0.107 master-192.56.0.107
# linux_2023_11 5     r      STARTED 867480195 228.1gb 192.56.0.108 master-192.56.0.108

#找到分片状态为UNASSIGNED( 非STARTED ), 对未分配的分片序号,查看原因
GET _cluster/allocation/explain
{
  "index":"linux_2023_11",
  "shard":0,
  "primary":true
}

#统一设置,重新分配分片
POST _cluster/reroute?retry_failed=true
#如果还是该索引还是red, 分配不了,可以尝试手动重新分配
POST  /_cluster/reroute
{
  "commands": [
    {
      "allocate_empty_primary": {
        "index": "linux_2023_11",
        "shard": 1,
        "node": "master-192.56.0.107",
        "accept_data_loss": true
      }
    }
  ]
}
相关推荐
Zaimmm14 小时前
临床文献智能检索哪家强?2026年主流AI循证平台深度测评与推荐
大数据·人工智能·microsoft
QYR_Jodie14 小时前
2026-2032全球玻璃纤维网市场分析:2032年将达到5.55亿美元
大数据·人工智能
八角Z14 小时前
AI Agent作为经济参与者的兴起:机器经济与传统金融体系的并存与交织
大数据·人工智能·服务发现
hyf32663314 小时前
高收益玩法:站群泛程序结合本地服务引流变现全流程
运维·服务器·前端·搜索引擎·蜘蛛池
资深电气设计14 小时前
数据中心800V直流断路器选型分析:ABB电气产品矩阵的技术适配性与评估要点
大数据·线性代数·矩阵
hzp66614 小时前
hudi学习0:目录
大数据·hudi
Elasticsearch14 小时前
跳过 mapping 爆炸:ES|QL 无需动态 mapping 即可查询无 schema JSON key
elasticsearch
智圣新创0115 小时前
嵌入一网通办体系的师生诉求响应机制建设 智圣新创“校长帮”模式的全国高校复用指南
大数据
金融小师妹15 小时前
多因子智能推演:7月零售销售下降,美元与黄金如何响应的AI传导框架
大数据·深度学习·逻辑回归
pingao14137815 小时前
金属翻斗式雨量筒 承雨口径200mm 高精度雨量监测仪
大数据·人工智能·科技