ElasticSearch 自动删除索引 (索引生命周期管理)
2019-10-22 本文已影响0人
ZhiXiong
必要条件: index 是必须根据 template 创建的,没有根据模板创建的 index 不能被自动删除。
完整示例:
1. 创建 index template
![](https://img.haomeiwen.com/i5872330/a62c2c781286470a.png)
2. 创建 index
![](https://img.haomeiwen.com/i5872330/f1bcb3353ccde397.png)
3. 创建 Index Lifecycle Policies 并与 template 关联
① 在 Kibana management 中点击 Index Lifecycle Policies
, 然后点击 Create pollcy
![](https://img.haomeiwen.com/i5872330/7e8541d9d98b08a4.png)
② 填写具体的 Policy name 以及其他配置并保存。这里是自动删除 7 天前创建的 index。
![](https://img.haomeiwen.com/i5872330/6991ce262cbf99d5.png)
③ 然后把 Index Lifecycle Policy 和 template 关联
![](https://img.haomeiwen.com/i5872330/314b03e16af533f4.png)
![](https://img.haomeiwen.com/i5872330/8ba4ef45f5d7bcf2.png)
④ 至此新创建的 xx-log* index 会在七天后自动删除
官方文档:
https://www.elastic.co/guide/en/elasticsearch/reference/7.3/index-lifecycle-management.html