乐趣区

关于elasticsearch:ES索引生命周期管理001

测试过程

  1. 批改 ilm 检测周期
    indices.lifecycle.poll_interval 默认是 10min,批改为10s
PUT _cluster/settings
{
  "persistent": {"indices.lifecycle.poll_interval": "10s"}
}
  1. 创立测试策略和模版
    (1)创立策略,每写入 5 个文档,即触发滚动策略,滚出新的索引
PUT _ilm/policy/rollover_test_policy
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0",
        "actions": {
          "set_priority": {"priority": 100},
          "rollover": {"max_docs": 5}
        }
      },
      "warm": {
        "min_age": "0",
        "actions": {
          "set_priority": {"priority": 50},
          "forcemerge": {"max_num_segments": 1}
        }
      },
      "cold": {
        "min_age": "1d",
        "actions": {
          "set_priority": {"priority": 0},
          "freeze": {}}
      },
      "delete": {
        "min_age": "1d",
        "actions": {"delete": {}
        }
      }
    }
  }
}
  1. 创立模版,应用下面创立的生命周期管理策略
PUT _template/rollover_test_template
{
  "index_patterns": ["rollover_test-*"],
  "settings": {
    "index.lifecycle.name": "rollover_test_policy",
    "index.lifecycle.rollover_alias": "rollover_test_alias",
    "number_of_replicas": 0,
    "number_of_shards": 1
  }
}
  1. 创立初始的索引
PUT rollover_test-000001 
{
  "aliases": {
    "rollover_test_alias":{"is_write_index": true}
  }
} 

由下面信息,能够失去 rollover_test-000001 处于 hot 阶段的 rollover 步骤查看中

  1. 通过写入文档,主动触发 rollover 滚动
GET _alias/rollover_test_alias
{
  "rollover_test-000001" : {
    "aliases" : {
      "rollover_test_alias" : {"is_write_index" : false}
    }
  },
  "rollover_test-000002" : {
    "aliases" : {
      "rollover_test_alias" : {"is_write_index" : true}
    }
  }
}

参考:
https://segmentfault.com/a/11…

退出移动版