Elasticsearch关于unassigned shards修复
来源:互联网 发布:气相色谱图数据怎么看 编辑:程序博客网 时间:2024/05/20 02:52
ES 版本: 5.2.1
步骤:
- curl localhost:9200/_cat/shards > shards
- 跑脚本:nohup python recovery.py &
### 注意:跑脚本过程会返回大量json,时间较长,请注意放入后台 - 查看修复shard进度:curl 127.0.0.1:9200/_cat/recovery/你修复shard对应的索引
- 结果: 找到索引对应的shard,看到existing_store done说明已经从本地修复
index 19 268ms existing_store done n/a n/a 10.0.58.67 node_name
#!/usr/bin/env python#name: recovery.pyimport requestsimport jsonhost = "http://localhost:9200/_cluster/allocation/explain"s= requests.Session()def reroute_shard(index,shard,node): data = { "commands" : [ { "allocate_stale_primary" : { "index" : index, "shard" : shard, "node" : node, "accept_data_loss": True } } ] } print data url = "http://localhost:9200/_cluster/reroute" res = s.post(url,json=data) print resdef get_node(line): if "UNASSIGNED" in line: line = line.split() index = line[0] shard = line[1] if line[2] != "p": return body = { "index": index, "shard": shard, "primary": True } res = s.get(host, json = body) for store in res.json().get("node_allocation_decisions"): if store.get("store").get("allocation_id"): node_name = store.get("node_name") reroute_shard(index,shard,node_name) else: returnwith open("shards", 'rb') as f: map(get_node,f)
相关文档:
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/cluster-reroute.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.2/cluster-allocation-explain.html
阅读全文
0 0
- Elasticsearch关于unassigned shards修复
- Elasticsearch关于unassigned shards的查看
- Elasticsearch关于unassigned shards的查看
- elasticsearch shard UNASSIGNED 修复
- elasticsearch的unassigned shards的处理(续)
- elsatic 出现unassigned shards的手工修复方法
- es大量unassigned shards
- ES: resolve unassigned shards
- elasticsearch外场分片找回-UNASSIGNED
- 关于kibana查询elasticsearch的index提示Courier Fetch: 4 of 6 shards failed.处理方法
- Optimizing Elasticsearch: How Many Shards per Index?
- elasticsearch索引修复
- elasticsearch------索引修复
- Elasticsearch的核心概念cluster/shards/replicas/recovery/gateway/discovery.zen/transport/settings/mapping等
- 分布式搜索elasticsearch------索引修复
- 分布式搜索elasticsearch------索引修复
- 分布式搜索elasticsearch------索引修复
- 分布式搜索elasticsearch------索引修复
- 清单文件引用
- 【loj6159】「美团 CodeM 初赛 Round A」最长树链
- 树莓派 liunx 无线路由器
- FineReport 9.0 破解注册原理以及教程
- leetcode 677. Map Sum Pairs
- Elasticsearch关于unassigned shards修复
- Python3 初学实践案例(11)判断质数以及计算一个数字的质因数
- hdu4292 food
- 集成开发环境VS 程序调试时逐语句与逐过程的区别
- 64位win10系统无法安装.Net framework3.5的两种解决方法
- 微服务治理之道
- Java之学习过错(三)
- Python笔记 NO.2
- 单片机实验7