最近更新时间:2021-03-03 16:34:28
本文介绍应用策略到索引的两种方式。
curl -X PUT "localhost:9200/_template/my_template?pretty" -H 'Content-Type: application/json' -d'
{
"index_patterns": ["test-*"],
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"index.lifecycle.name": "my_policy",
"index.lifecycle.rollover_alias": "test-alias"
}
}
'
满足这个模板的新建索引会自动应用策略my_policy,如果策略中包含rollover,还需要初始化索引。
curl -X PUT "localhost:9200/test-000001?pretty" -H 'Content-Type: application/json' -d'
{
"aliases": {
"test-alias":{
"is_write_index": true
}
}
}
'
curl -X PUT "localhost:9200/test-index?pretty" -H 'Content-Type: application/json' -d'
{
"settings": {
"index.lifecycle.name": "my_policy"
}
}
'
查看集群当前的ilm策略:
curl -XGET localhost:9200/_ilm/policy?pretty
查看索引test-index生命周期管理执行的状态:
curl -XGET localhost:9200/test-index/_ilm/explain?pretty
纯净模式