ES集群状态red修复
总结
一、遇到集群Red时,我们可以从如下方法排查:
集群层面:/_cluster/health。
索引层面:/_cluster/health?pretty&level=indices。
分片层面:/_cluster/health?pretty&level=shards。
看恢复情况:/_recovery?pretty。
二、有unassigned分片的排查思路
_cluster/allocation/explain 先诊断。
/_cluster/reroute 尝试重新分配。
三、数据重放
如果实在恢复不了,那只能索引重建了。提供一种思路:
先新建备份索引
curl -XPUT ‘http://xxxx:9200/a_index_copy/‘ -d ‘{
“settings”:{
“index”:{
“number_of_shards”:3,
“number_of_replicas”:2
}
}
}
通过reindex,将目前可用的数据导入:
POST _reindex
{
"source": {
"index": "a_index"
},
"dest": {
"index": "a_index_copy",
"op_type": "create"
}
}
删除a_index索引,这个必须要先做,否则别名无法添加.
curl -XDELETE 'http://xxxx:9200/a_index'
创建a_index_copy索引
curl -XPUT ‘http://xxxx:9200/a_index_copy/‘ -d ‘{
“settings”:{
“index”:{
“number_of_shards”:3,
“number_of_replicas”:2
}
}
}
通过reindex api将a_index数据copy到a_index_copy。
POST _reindex
{
"source": {
"index": "a_index"
},
"dest": {
"index": "a_index_copy",
"op_type": "create"
}
}
删除a_index索引,这个必须要先做,否则别名无法添加
curl -XDELETE 'http://xxxx:9200/a_index'
给a_index_copy添加别名a_index
curl -XPOST 'http://xxxx:9200/_aliases' -d '
{
"actions": [
{"add": {"index": "a_index_copy", "alias": "a_index"}}
]
}'
四、translog总结
translog在节点有问题时,能够帮助阻止数据的丢失
设计目的:
1、帮助节点从失败从快速恢复。
2、辅助flush。避免在flush过程中数据丢失。
如对您有帮助,支持下呗!
微信

支付宝

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
2019-06-09 docker镜像批量打包
2019-06-09 二进制安装docker-18.06.3-ce