共计 1198 个字符,预计需要花费 3 分钟才能阅读完成。
测试过程
- 批改
ilm
检测周期indices.lifecycle.poll_interval
默认是10min
,批改为10s
PUT _cluster/settings
{
"persistent": {"indices.lifecycle.poll_interval": "10s"}
}
- 创立测试策略和模版
(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": {}
}
}
}
}
}
- 创立模版,应用下面创立的生命周期管理策略
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
}
}
- 创立初始的索引
PUT rollover_test-000001
{
"aliases": {
"rollover_test_alias":{"is_write_index": true}
}
}
由下面信息,能够失去 rollover_test-000001 处于 hot 阶段的 rollover 步骤查看中
- 通过写入文档,主动触发 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}
}
}
}
参考:
https://segmentfault.com/a/11…
正文完
发表至: elasticsearch
2022-08-31