清理ElasticSearch索引数据

前言

ElasticSearch是一个开源的搜索引擎,它可以存储、索引和搜索大量的数据。当数据量越来越大时,索引数据会越来越多,这时需要对索引数据进行清理,以避免占用过多的磁盘空间。

清理索引数据

参考官网链接:https://www.elastic.co/guide/en/elasticsearch/client/curator/8.0/installation.html

下载docker镜像

docker pull untergeek/curator:8.0.17

确认es索引前缀

curl -u elastic:B2tdZ31TLwtq http://172.22.150.80:9200/_cat/indices

创建目录

/data/elasticsearch-8.12.2/curator/actions

创建action-file.yaml文件

actions:
1:
action: delete_indices
description: "删除超过30天的索引"
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: "llmstudio-" # 只对以'llmstudio-'开头的索引进行操作
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 30

运行命令

docker run --rm -v /etc/localtime:/etc/localtime -v /data/elasticsearch-8.12.2/curator/actions:/actions   untergeek/curator:8.0.17 --hosts http://x.x.x.x:9200 --username elastic --password xxxxxxx /actions/action-file.yaml
文章作者: 慕容峻才
文章链接: https://www.acaiblog.top/清理ElasticSearch索引数据/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 阿才的博客
微信打赏
支付宝打赏