指标平台数据停留在前一天,通过服务日志排查到ES出现异常,无法写入,进入到kibana发现ES集群状态red。
ES集群有6个节点,每日写入量接近100G,ES节点1、节点2磁盘大小为1.7T,另外4个ES节点磁盘大小为2.2T,由于长期未关注ES磁盘空间占用情况,节点1、节点2磁盘使用率达到85%,导致集群状态red。
2.1 当前问题
2.2 排查过程
curl -X DELETE http://elastic:elastic@IP:9200/索引
curl -X DELETE http://elastic:elastic@IP:9200/metric_dbl_2022*
curl http://elastic:elastic@IP:9200/_cat/health?v

curl -XGET 'http://elastic:elastic@IP:9200/_cat/nodes?v'

curl -XGET 'http://elastic:elastic@IP:9200/_cat/nodes?v'

如果是索引red的问题,可以选择重构red的索引,或者删除索引,当前我们选择重构索引。
3.1 查看索引结构
curl http://elastic:elastic@localhost:9200/索引
3.2 新建临时索引
curl -X PUT http://elastic:elastic@localhost:9200/索引_back
3.3 拷贝临时索引
curl -X POST -H "Content-Type: application/json" http://elastic:elastic@localhost:9200/_reindex -d '{"source":{"index":"索引"},"dest":{"index":"索引_back"}}'
3.4 查询索引状态
curl http://elastic:elastic@localhost:9200/_cat/indices
3.5 删除旧的索引
curl -X DELETE http://elastic:elastic@localhost:9200/索引
sh elastic.sh start
3.6 还原数据
curl -X POST -H "Content-Type: application/json" http://elastic:elastic@localhost:9200/_reindex -d '{"source":{"index":"索引_back"},"dest":{"index":"索引"}}'
3.7 删除临时索引
curl -X DELETE http://elastic:elastic@localhost:9200/索引_back
建 议:
1)定时检查磁盘剩余空间,保证空间处于正常范围内; 2)设置索引有效期,将超过一定期限的索引进行删除; 3)定时检查ES索引状态,一旦发现问题及时排查。

本文作者:事业二部(上海新炬中北团队)
本文来源:“IT那活儿”公众号

文章转载自IT那活儿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




