elasticsearch集群状态的疑问
medcl 回复了问题 • 4 人关注 • 2 个回复 • 2246 次浏览 • 2018-01-16 11:01
Elasticsearch关于unassigned shards修复
arterforyou 发表了文章 • 2 个评论 • 6057 次浏览 • 2017-12-23 12:23
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说明已经从本地修复
shell<br /> index 19 268ms existing_store done n/a n/a 10.0.58.67 node_name<br />
```python
!/usr/bin/env python
name: recovery.py
import requests
import json
host = "<a href="http://localhost:9200/_cluster/allocation/explain"" rel="nofollow" target="_blank">http://localhost:9200/_cluster ... ot%3B
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 = "<a href="http://localhost:9200/_cluster/reroute"" rel="nofollow" target="_blank">http://localhost:9200/_cluster/reroute"
res = s.post(url,json=data)
print res
def 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:
return
with open("shards", 'rb') as f:
map(get_node,f)
```
相关文档:- https://www.elastic.co/guide/e ... .html
- https://www.elastic.co/guide/e ... .html
- https://www.elastic.co/guide/e ... .html
elasticsearch安装插件需要重启的问题
medcl 回复了问题 • 5 人关注 • 1 个回复 • 5441 次浏览 • 2018-01-16 11:17
elastcsearch批量删除重复的document
guoyuan 回复了问题 • 4 人关注 • 3 个回复 • 5059 次浏览 • 2020-09-17 16:32
elasticsearch出现查询慢如何排查问题
kennywu76 回复了问题 • 4 人关注 • 1 个回复 • 16509 次浏览 • 2017-12-22 14:24
es script 字段 如何进行多值搜索?
medcl 回复了问题 • 2 人关注 • 2 个回复 • 7171 次浏览 • 2018-01-16 11:25
请问下ES可以做类似sql的like,要后匹配的like,比如:like ‘aaaaa%’这样的
LXJ 回复了问题 • 3 人关注 • 3 个回复 • 13737 次浏览 • 2018-01-08 17:43
统计图书clcs字段中'建筑科学'出现的次数
strglee 回复了问题 • 2 人关注 • 1 个回复 • 1865 次浏览 • 2017-12-22 19:01
jvm heap使用率超过80%
kennywu76 回复了问题 • 4 人关注 • 1 个回复 • 9789 次浏览 • 2017-12-22 14:09
ES老版本下载
shitangjiejie 回复了问题 • 3 人关注 • 2 个回复 • 13838 次浏览 • 2017-12-21 18:02
elasticsearch java api 太少了不全面
phoenix 回复了问题 • 4 人关注 • 3 个回复 • 3069 次浏览 • 2017-12-21 17:49