如何在Amazon OpenSearch Serverless中配置索引自动删除及访问IndexManagement
在Amazon OpenSearch Serverless中实现索引自动删除及IndexManagement入口问题解答
一、实现索引自动删除(替代传统ISM)
Amazon OpenSearch Serverless不支持传统托管集群中的Index State Management(ISM),而是通过**生命周期策略(Lifecycle Policies)**来实现索引的自动清理,具体操作如下:
1. 创建生命周期策略
你可以通过AWS控制台、CLI或API来创建策略,以下是两种常用方式:
控制台操作
- 登录AWS控制台,进入Amazon OpenSearch Serverless服务页面
- 选择目标集合,切换到Lifecycle policies标签页
- 点击Create lifecycle policy,设置:
- 策略名称(如
auto-delete-daily-indexes) - 策略类型选择
INDEX - 索引模式匹配你的日期型索引(如
your-index-pattern-*,比如logs-2024-*) - 添加规则:设置触发条件为索引创建后N天(如
7d),动作选择Delete
- 策略名称(如
- 保存策略
CLI命令示例
使用AWS CLI执行以下命令(替换参数为你的实际配置):
aws opensearchserverless create-lifecycle-policy \ --name auto-delete-daily-indexes \ --type INDEX \ --policy '{ "rules": [ { "rule_id": "delete-after-7-days", "description": "Auto delete indexes 7 days after creation", "condition": { "index_age": "7d" }, "actions": [ { "delete": {} } ] } ] }'
2. 关联策略到集合
创建完成后,需要将该生命周期策略关联到目标集合,确保策略能作用到集合内的所有匹配索引。在控制台的策略列表中,找到刚创建的策略,点击Associate collections,选择目标集合即可。
二、IndexManagement模块入口问题
Amazon OpenSearch Serverless的OpenSearch Dashboard中没有传统的Index Management模块,这是因为Serverless版本将生命周期管理、索引配置等功能迁移到了AWS控制台层面,而非Dashboard内的插件。即使你为用户配置了全数据访问权限,也无法在Dashboard中看到该模块。
所有与索引生命周期相关的配置,都需要通过AWS控制台、CLI或API完成,而非Dashboard操作。
内容的提问来源于stack exchange,提问作者Gautam
相关产品推荐
相关产品推荐

