3 个回答
总体思路如下:
1、创建ILM策略,比如热节点保留30天,之后删除
1、创建ILM策略,比如热节点保留30天,之后删除
PUT _ilm/policy/order_logs_policy
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_size": "50gb",
"max_age": "1d"
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {}
}
}
}
}
}
发布于:1个月前 (03-21) IP属地:四川省
2、接着定义索引的模板,里面自动应用上面创建的ILM
PUT _index_template/order_logs_template
{
"index_patterns": ["order_logs-*"],
"template": {
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1,
"index.lifecycle.name": "order_logs_policy",
"index.routing_path": ["order_id"] # 优化时序数据写入
},
"mappings": {
"properties": {
"order_id": { "type": "keyword" },
"timestamp": { "type": "date" },
"amount": { "type": "double" },
"status": { "type": "keyword" }
}
}
}
}
发布于:1个月前 (03-21) IP属地:四川省
2、接着定义索引的模板,里面自动应用上面创建的ILM
PUT _index_template/order_logs_template
{
"index_patterns": ["order_logs-*"],
"template": {
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1,
"index.lifecycle.name": "order_logs_policy",
"index.routing_path": ["order_id"] # 优化时序数据写入
},
"mappings": {
"properties": {
"order_id": { "type": "keyword" },
"timestamp": { "type": "date" },
"amount": { "type": "double" },
"status": { "type": "keyword" }
}
}
}
}
3、初始化第一个索引,后续自动滚动
PUT order_logs-000001{ "aliases": { "current_order_logs": { # 查询统一走别名 "is_write_index": true } }}
发布于:1个月前 (03-21) IP属地:四川省
我来回答
您需要 登录 后回答此问题!