乐趣区

关于elasticsearch: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"}
}
退出移动版