elasticsearch进阶(3)—— ilm policy

一、参考

elasticsearch 学习系列目录——更新ing

官方文档 ilm

使用索引生命周期管理实现热温冷架构

二、基本使用

2.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.2 创建模版

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

2.3 手动创建第一个索引

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

2.4 缩短查看生命周期时间

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

你可能感兴趣的:(elasticsearch)