一、参考
二、测试过程
2.1 修改ilm
检测周期
indices.lifecycle.poll_interval
默认是 10min
, 修改为10s
PUT _cluster/settings
{
"persistent": {
"indices.lifecycle.poll_interval": "10s"
}
}
2.2 创建测试策略和模版
(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": {}
}
}
}
}
}
(2)创建模版,使用上面创建的生命周期管理策略,
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
}
}
(3)创建初始的索引
PUT rollover_test-000001
{
"aliases": {
"rollover_test_alias":{
"is_write_index": true
}
}
}
由上面信息,可以得到 rollover_test-000001
处于 hot
阶段的rollover
步骤检查中
2.3 通过写入文档,自动触发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
}
}
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。