ElasticSearch 排障常用方法

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

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
# 查看帮助: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
      }
    }
  ]
}

相关推荐

  1. ElasticSearch 方法

    2023-12-08 18:02:05       45 阅读
  2. ElasticSearch 查询优化方式

    2023-12-08 18:02:05       11 阅读
  3. apache

    2023-12-08 18:02:05       38 阅读
  4. elasticsearch命令

    2023-12-08 18:02:05       29 阅读
  5. Elasticsearch语句

    2023-12-08 18:02:05       17 阅读
  6. Linux查问题命令

    2023-12-08 18:02:05       7 阅读
  7. Elasticsearch 优化思路

    2023-12-08 18:02:05       36 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-08 18:02:05       17 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-08 18:02:05       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-08 18:02:05       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-08 18:02:05       18 阅读

热门阅读

  1. 判断path是文件夹,文件,还是不存在

    2023-12-08 18:02:05       42 阅读
  2. C++基础 std::funtion简说

    2023-12-08 18:02:05       40 阅读
  3. 多线程解决大数据批量导出问题(demo)

    2023-12-08 18:02:05       40 阅读
  4. VS2010 VS2015环境编译boost库

    2023-12-08 18:02:05       29 阅读
  5. 移植OpenSSH到DM IPNC中的Linux ARM SSH编程

    2023-12-08 18:02:05       45 阅读
  6. Sentinel与SpringBoot整合

    2023-12-08 18:02:05       32 阅读
  7. Spring 之 @Cacheable 缓存使用教程

    2023-12-08 18:02:05       37 阅读
  8. LeetCode算法练习top100:(6)图论

    2023-12-08 18:02:05       28 阅读