配置项作用 #
index_state_management.history.rollover_retention_period 配置项用于控制滚动后的历史索引在被删除前的保留时间。
当历史索引滚动后(创建新索引),旧索引会根据此配置保留一段时间,超过保留期的索引会被自动删除。
配置项属性 #
- 配置路径:
index_state_management.history.rollover_retention_period - 数据类型:
TimeValue(时间值) - 默认值:
30d(30天) - 最小值:
> 0(正数) - 是否可选: 是
- 作用域: NodeScope(节点级别)
- 动态更新: 是(支持动态更新)
配置项详解 #
工作机制 #
历史索引生命周期管理
索引创建 (.ism-history-000001)
│
↓
记录历史数据
│
↓
触发滚动 (达到 max_docs 或 max_age)
│
↓
创建新索引 (.ism-history-000002)
│
↓
旧索引进入保留期
│
↓
定期检查 (rollover_check_period)
│
├──── 存在时间 < retention_period ──→ 保留 ✅
│
└──── 存在时间 ≥ retention_period ──→ 删除 ❌
│
↓
索引被删除
保留期计算 #
索引保留期计算
索引创建时间:
2024-01-01 10:00:00
当前时间:
2024-01-31 10:00:00
索引存在时间:
= 当前时间 - 创建时间
= 30 天
rollover_retention_period = 30d:
存在时间 = 30d ≥ 30d
↓
删除索引 ✅
rollover_retention_period = 7d:
存在时间 = 30d ≥ 7d
↓
早已删除 ✅
滚动索引与活跃索引 #
索引状态区分
活跃索引:
.ism-history (别名)
↓ 指向
.ism-history-000003 (最新)
↓
✅ 不会被删除
↓ (即使超过保留期)
滚动索引:
.ism-history-000001
.ism-history-000002
↓
检查创建时间
↓
超过 retention_period?
↓
✅ 可能被删除
配置建议 #
生产环境(默认) #
index_state_management:
history:
rollover_retention_period: 30d # 默认值
建议: 保持默认值 30d。适用于大多数场景。
短期审计需求 #
index_state_management:
history:
rollover_retention_period: 7d # 7 天
建议: 减少到 3-7d。不需要长期历史时使用。
长期审计需求 #
index_state_management:
history:
rollover_retention_period: 90d # 90 天
建议: 增加到 60-90d。需要长期审计时使用。
存储受限环境 #
index_state_management:
history:
rollover_retention_period: 3d # 3 天
建议: 减少到 1-3d。存储空间紧张时使用。
代码示例 #
easysearch.yml 基础配置 #
index_state_management:
history:
rollover_retention_period: 30d
配合其他历史配置 #
index_state_management:
history:
enabled: true
max_age: 24h
max_docs: 2500000
rollover_check_period: 8h
rollover_retention_period: 30d
短期保留配置 #
index_state_management:
history:
max_age: 6h
rollover_check_period: 1h
rollover_retention_period: 7d
动态更新配置 #
PUT /_cluster/settings
{
"transient": {
"index_state_management.history.rollover_retention_period": "60d"
}
}
相关配置 #
| 配置项 | 作用 | 默认值 |
|---|---|---|
index_state_management.history.enabled | 是否启用历史记录 | true |
index_state_management.history.max_age | 历史索引最大年龄 | 24h |
index_state_management.history.max_docs | 历史索引最大文档数 | 2500000 |
index_state_management.history.rollover_check_period | 滚动检查周期 | 8h |
index_state_management.history.rollover_retention_period | 历史索引保留期 | 30d |
存储影响分析 #
保留期与存储消耗
假设每天滚动一个索引,每个索引 25GB
retention_period = 7d:
保留索引数 ≈ 7 个
总存储 ≈ 7 × 25GB = 175GB
retention_period = 30d (默认):
保留索引数 ≈ 30 个
总存储 ≈ 30 × 25GB = 750GB
retention_period = 90d:
保留索引数 ≈ 90 个
总存储 ≈ 90 × 25GB = 2.25TB
使用场景 #
推荐使用默认值的场景 #
- 标准生产: 正常的审计和故障排查需求
- 充足存储: 有足够的存储空间
- 合规要求: 30 天满足大多数合规要求
推荐减少保留期的场景 #
- 存储受限: 存储空间紧张
- 短期审计: 只需要短期历史数据
- 快速测试: 测试环境快速清理
推荐增加保留期的场景 #
- 长期审计: 需要长期保存操作历史
- 合规要求: 监管要求长期保留
- 故障排查: 需要追溯较长时间的历史
数据保留策略 #
典型的保留期策略
开发环境:
retention_period = 1-3d
特点: 快速迭代,历史不重要
测试环境:
retention_period = 3-7d
特点: 测试验证,短期历史
预发布环境:
retention_period = 14-30d
特点: 接近生产,中等历史
生产环境:
retention_period = 30-90d
特点: 生产审计,长期历史
合规环境:
retention_period = 180-365d
特点: 监管要求,超长历史
删除操作说明 #
过期索引删除流程
定期检查 (rollover_check_period)
│
↓
扫描所有历史索引
│
↓
排除活跃索引
│
↓
检查每个滚动索引的创建时间
│
├──── 存在时间 < retention_period
│ │
│ └──── 保留 ✅
│
└──── 存在时间 ≥ retention_period
│
↓
删除索引
│
↓
释放存储
注意事项 #
默认值: 默认值为
30d,适合大多数场景。活跃索引: 当前活跃的历史索引不会被删除。
存储规划: 需要根据保留期规划存储空间。
删除时间: 实际删除时间取决于检查周期。
动态更新: 支持动态更新,修改后立即生效。
数据恢复: 删除后的索引无法恢复(除非有备份)。
备份策略: 应该在删除前完成备份。
合规要求: 某些行业有特定的数据保留要求。
与 max_age 配合: 保留期应该远大于滚动年龄。
监控建议: 监控历史索引的数量和总存储占用。





