• 【ElasticSearch】更新es索引生命周期策略,策略何时对索引生效


    大家好,我是好学的小师弟,今天和大家讨论下更新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状态

    1. {
    2. "indices": {
    3. "test_2023.03.21-000001": {
    4. "index": "test_2023.03.21-000001",
    5. "managed": true,
    6. "policy": "test",
    7. "lifecycle_date_millis": 1679394264357, //2023-03-21 18:24:24
    8. "age": "203.41d",
    9. "phase": "hot",
    10. "phase_time_millis": 1693479366940, //2023-08-31 18:56:06
    11. "action": "rollover",
    12. "action_time_millis": 1679394338025, //2023-03-21 18:25:38
    13. "step": "check-rollover-ready",
    14. "step_time_millis": 1693479366940, //2023-08-31 18:56:06
    15. "is_auto_retryable_error": true,
    16. "failed_step_retry_count": 2,
    17. "phase_execution": {
    18. "policy": "test",
    19. "phase_definition": {
    20. "min_age": "3ms",
    21. "actions": {
    22. "rollover": {
    23. "max_size": "4831838208b"
    24. },
    25. "set_priority": {
    26. "priority": 100
    27. }
    28. }
    29. },
    30. "version": 5,
    31. "modified_date_in_millis": 1696969009629 //2023-10-11 04:16:49
    32. }
    33. }
    34. }
    35. }

    3.更新完索引生命周期策略后,新策略已经对索引生效,索引符合新的策略的滚动条件,滚动中

    1. {
    2. "indices": {
    3. "test_2023.03.21-000001": {
    4. "index": "test_2023.03.21-000001",
    5. "managed": true,
    6. "policy": "test",
    7. "lifecycle_date_millis": 1679394264357, //2023-03-21 18:24:24
    8. "age": "203.41d",
    9. "phase": "hot",
    10. "phase_time_millis": 1693479366940, //2023-08-31 18:56:06
    11. "action": "rollover",
    12. "action_time_millis": 1679394338025, //2023-03-21 18:25:38
    13. "step": "attempt-rollover", //这里已经开始尝试滚动
    14. "step_time_millis": 1696969116221, //2023-10-11 04:18:36
    15. "phase_execution": {
    16. "policy": "test",
    17. "phase_definition": {
    18. "min_age": "3ms",
    19. "actions": {
    20. "rollover": {
    21. "max_size": "4831838208b" //这里已经适配了最新的策略4.5G
    22. },
    23. "set_priority": {
    24. "priority": 100
    25. }
    26. }
    27. },
    28. "version": 5,
    29. "modified_date_in_millis": 1696969009629 //2023-10-11 04:16:49
    30. }
    31. }
    32. }
    33. }

    4.下面的是策略生效,索引滚动完毕,已经进入warm阶段

    1. {
    2. "indices": {
    3. "test_2023.03.21-000001": {
    4. "index": "test_2023.03.21-000001",
    5. "managed": true,
    6. "policy": "test",
    7. "lifecycle_date_millis": 1696969219587, //2023-10-11 04:20:19
    8. "age": "13.12h",
    9. "phase": "warm",
    10. "phase_time_millis": 1696969755909, //2023-10-11 04:29:15
    11. "action": "complete",
    12. "action_time_millis": 1696972068230, //2023-10-11 05:07:48
    13. "step": "complete",
    14. "step_time_millis": 1696972068230, //2023-10-11 05:07:48
    15. "phase_execution": {
    16. "policy": "test",
    17. "phase_definition": {
    18. "min_age": "5ms",
    19. "actions": {
    20. "allocate": {
    21. "number_of_replicas": 0,
    22. "include": {},
    23. "exclude": {
    24. "box_type": "cold,hot"
    25. },
    26. "require": {
    27. "box_type": "warm"
    28. }
    29. },
    30. "forcemerge": {
    31. "max_num_segments": 1
    32. },
    33. "set_priority": {
    34. "priority": 50
    35. },
    36. "shrink": {
    37. "number_of_shards": 1
    38. }
    39. }
    40. },
    41. "version": 5,
    42. "modified_date_in_millis": 1696969009629 //2023-10-11 04:16:49
    43. }
    44. }
    45. }
    46. }

    新人创作不易,觉得不错的看官,点个赞吧,么么哒!!!

    转载注明出处!

                                                         

  • 相关阅读:
    SELinux零知识学习十一、SELinux策略语言之客体类别和许可(5)
    Spring 系列(三):你真的懂@RequestMapping吗?
    Linux更新g++
    python枚举详解
    Shell脚本:Linux Shell脚本学习指南(第一部分Shell基础)二
    基于JavaWEB SpringBoot婚纱影楼摄影预约网站设计和实现
    Tomcat过时了?别多想,很多公司还是在用的。这份Tomcat架构详解,真的颠覆你的认知
    一种KV存储的GC优化实践
    公司电脑屏幕录制软件有什么功能
    浅谈多回路电表在荷兰光伏系统配电项目中的应用
  • 原文地址:https://blog.csdn.net/weixin_43784564/article/details/133780658