elasticsearch进阶(3)—— ilm policy

基本使用

1.创建生命周期策略

PUT _ilm/policy/yztest-policy
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_size": "50gb",
            "max_age": "30d",
            "max_docs": 5
          },
          "set_priority": {
            "priority": 100
          }
        }
      },
      "warm": {
        "min_age": "3d",
        "actions": {
          "readonly": {},
          "set_priority": {
            "priority": 50
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

2.创建模版

PUT _template/yztest-template
{
  "index_patterns": ["yztest-*"],
  "settings": {
    "index.lifecycle.name": "yztest-policy",
    "index.lifecycle.rollover_alias": "yztest-alias" 
  }
}

3.手动创建第一个索引

PUT yztest-000001 
{
  "aliases": {
    "yztest-alias":{
      "is_write_index": true 
    }
  }
} 

4.缩短查看生命周期时间

PUT _cluster/settings
{
  "persistent": {
    "indices.lifecycle.poll_interval" : "5s"
  }
}

如果你想开发软件或者APP的话,可以通过第三方专业开发平台,来帮助你实现开发需求:厦门在乎科技-专注小程序开发、厦门app开发、网站开发

上一篇:爱上MVC系列~过滤器实现对响应流的处理


下一篇:linux——用户管理