大家好,我是好学的小师弟,今天和大家讨论下更新es索引生命周期策略后,策略何时对索引生效
结论:
若当前索引已应用策略A(旧),更新完策略A后,新的策略A会立即对原来的已经应用该策略的索引生效;若当前索引符合新策略A的生命周期变化条件,则会自动进入下一阶段(hot-warm-cold-delete)
举例:
比方说原来策略是10g就滚动索引,你现在索引大小为8G,不符合滚动条件,但是你更新的策略为4G,那么更新策略完成后,等待一段时间(10分钟左右),索引即可完成滚动,因为8G符合4g的滚动条件
具体细节:
1.几个关键字段
以下字段value均是时间戳,通过观察三张图里的这些时间戳,即可得出结论:更新后的策略对原来已经应用该策略的索引,立即生效
lifecycle_date_millis: 指的是索引创建的时间戳,这里的索引指的是一开始创建这个索引的时间,或者是滚动后新索引的创建时间
phase_time_millis: 索引进入当前生命周期阶段的时间戳,以毫秒为单位
action: 当前生命周期阶段执行的操作,可能的值包括:complete、delete、rollover。
action_time_millis: 执行当前操作的时间戳,跟action字段对应
step_time_millis: 执行当前子步骤的时间戳,跟step字段对应
modified_date_in_millis: 索引生命周期策略的修改时间戳
2.更新完索引生命周期策略后,新策略已经对索引生效,索引目前处于check policy状态
{
"indices": {
"test_2023.03.21-000001": {
"index": "test_2023.03.21-000001",
"managed": true,
"policy": "test",
"lifecycle_date_millis": 1679394264357, //2023-03-21 18:24:24
"age": "203.41d",
"phase": "hot",
"phase_time_millis": 1693479366940, //2023-08-31 18:56:06
"action": "rollover",
"action_time_millis": 1679394338025, //2023-03-21 18:25:38
"step": "check-rollover-ready",
"step_time_millis": 1693479366940, //2023-08-31 18:56:06
"is_auto_retryable_error": true,
"failed_step_retry_count": 2,
"phase_execution": {
"policy": "test",
"phase_definition": {
"min_age": "3ms",
"actions": {
"rollover": {
"max_size": "4831838208b"
},
"set_priority": {
"priority": 100
}
}
},
"version": 5,
"modified_date_in_millis": 1696969009629 //2023-10-11 04:16:49
}
}
}
}
3.更新完索引生命周期策略后,新策略已经对索引生效,索引符合新的策略的滚动条件,滚动中
{
"indices": {
"test_2023.03.21-000001": {
"index": "test_2023.03.21-000001",
"managed": true,
"policy": "test",
"lifecycle_date_millis": 1679394264357, //2023-03-21 18:24:24
"age": "203.41d",
"phase": "hot",
"phase_time_millis": 1693479366940, //2023-08-31 18:56:06
"action": "rollover",
"action_time_millis": 1679394338025, //2023-03-21 18:25:38
"step": "attempt-rollover", //这里已经开始尝试滚动
"step_time_millis": 1696969116221, //2023-10-11 04:18:36
"phase_execution": {
"policy": "test",
"phase_definition": {
"min_age": "3ms",
"actions": {
"rollover": {
"max_size": "4831838208b" //这里已经适配了最新的策略4.5G
},
"set_priority": {
"priority": 100
}
}
},
"version": 5,
"modified_date_in_millis": 1696969009629 //2023-10-11 04:16:49
}
}
}
}
4.下面的是策略生效,索引滚动完毕,已经进入warm阶段
{
"indices": {
"test_2023.03.21-000001": {
"index": "test_2023.03.21-000001",
"managed": true,
"policy": "test",
"lifecycle_date_millis": 1696969219587, //2023-10-11 04:20:19
"age": "13.12h",
"phase": "warm",
"phase_time_millis": 1696969755909, //2023-10-11 04:29:15
"action": "complete",
"action_time_millis": 1696972068230, //2023-10-11 05:07:48
"step": "complete",
"step_time_millis": 1696972068230, //2023-10-11 05:07:48
"phase_execution": {
"policy": "test",
"phase_definition": {
"min_age": "5ms",
"actions": {
"allocate": {
"number_of_replicas": 0,
"include": {},
"exclude": {
"box_type": "cold,hot"
},
"require": {
"box_type": "warm"
}
},
"forcemerge": {
"max_num_segments": 1
},
"set_priority": {
"priority": 50
},
"shrink": {
"number_of_shards": 1
}
}
},
"version": 5,
"modified_date_in_millis": 1696969009629 //2023-10-11 04:16:49
}
}
}
}
新人创作不易,觉得不错的看官,点个赞吧,么么哒!!!
转载注明出处!