我们创建了 ILM(索引生命周期管理)策略,使用匹配的索引模板和引导索引自动执行索引翻转,以启用具有别名的写入索引。
请找到以下 API 代码:
政策
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_size": "50mb",
"max_primary_shard_size": "50mb",
"max_age": "30m"
},
"set_priority": {
"priority": 200
}
}
},
"cold": {
"min_age": "5m",
"actions": {
"searchable_snapshot": {
"snapshot_repository": "found-snapshots",
"force_merge_index": true
},
"set_priority": {
"priority": 0
}
}
},
"frozen": {
"min_age": "10m",
"actions": {
"searchable_snapshot": {
"snapshot_repository": "found-snapshots",
"force_merge_index": true
}
}
},
"delete": {
"min_age": "1h",
"actions": {
"delete": {
"delete_searchable_snapshot": true
}
}
}
}
}
}
模板
PUT _index_template/sree
{
"index_patterns":["sree-*"],
"template":{
"settings":{
"number_of_shards":1,
"number_of_replicas":1,
"index.lifecycle.name":"sree",
"index.lifecycle.rollover_alias":"sree"
}
}
}
引导索引:
PUT sree-000001
{
"aliases":{
"sree":{
"is_write_index":true
}
}
}
注意:我正在使用 logstash 通过使用 elasticsearch 输出插件将数据发送到弹性搜索。
这是输出插件代码:
output {
elasticsearch {
hosts => "https:xyz:9243"
user => "elastic"
password => "xyz"
index => "sree-"
ilm_enabled => true
}
}
对于上述场景,我成功地创建了索引和索引别名,索引正在移动到下一个节点,如冷/冻结,但数据没有移动/迁移。