当前位置: 首页 > news >正文

ES 生命周期管理

一 .概念

ILM定义了四个生命周期阶段:
Hot:正在积极地更新和查询索引。
Warm:不再更新索引,但仍在查询。
cold:不再更新索引,很少查询。信息仍然需要可搜索,但是如果这些查询速度较慢也可以。
Delete:不再需要该索引,可以安全地将其删除

仅仅在 Hot阶段 可以设置 rollover滚动

在实验中可以修改设置,来缩短ILM检测时间间隔。ILM定期运行(indices.lifecycle.poll_interval),默认是10分钟,检查索引是否符合策略标准,并执行所需的任何步骤

PUT /_cluster/settings{ "transient": { "indices.lifecycle.poll_interval": "1m" } }

参数的设置:满足任意一个创建新的索引

HOT

WARM

Delete

二. 实战

1 .创建生命周期策略模板:PUT 请求

http://localhost:9099/_ilm/policy/my_index_rollover_policy

"max_docs": 5000000 设置超过500万是创建新的索引,实际测试可以设置小一点

{"policy": {"phases": {"hot": {"actions": {"rollover": {"max_docs": 5000000},"set_priority": {"priority": 100}}},"warm": {"min_age": "30d","actions": {"forcemerge": {"max_num_segments": 1},"shrink": {"number_of_shards": 1},"allocate": {"number_of_replicas": 1},"set_priority": {"priority": 50}}},"cold": {"min_age": "90d","actions": {"freeze": {},"allocate": {"require": {"type": "cold"}},"set_priority": {"priority": 10}}},"delete": {"min_age": "3650d","actions": {"delete": {}}}}}
}

2. 创建索引模板(日志统计索引) PUT 请求:

http://localhost:9099/_template/my_statistic_log

{"index_patterns": ["my_statistic_log-*"],"settings": {"index.number_of_shards": 5,"index.number_of_replicas": 1,"refresh_interval": "60s","index.lifecycle.name": "my_index_rollover_policy","index.lifecycle.rollover_alias": "statistic_log_write"},"aliases": {"statistic_log_read": {}},"mappings": {"log": {"dynamic": "strict","_field_names": {"enabled": false},"dynamic_templates": [{"date": {"match": "*Date","mapping": {"type": "date"}}},{"strings": {"match_mapping_type": "string","mapping": {"type": "keyword"}}},{"long_or_text": {"match": "*Time","mapping": {"type": "date"}}},{"dataFormat": {"match": "*Date","mapping": {"type": "date"}}},{"timeFormat": {"match": "*Time","mapping": {"type": "date"}}},{"noAnalyzed": {"match_mapping_type": "string","mapping": {"type": "keyword"}}}],"properties": {"area": {"type": "keyword"},"desc": {"type": "keyword"},"hour": {"type": "integer"},"day": {"type": "integer"},"startTime": {"type": "date","format": "yyyy-MM-dd HH:mm:ss"},"totalCount": {"type": "long"}}}}
}

3.    根据索引模板创建起始索引(日志统计索引)
put 请求: http://localhost:9099/my_statistic_log-000001

{"aliases": {"statistic_log_write": {"is_write_index": true}}
}

4.    查看索引生效:GET请求 
http://localhost:9099/my_statistic_log-000001/_ilm/explain

https://www.elastic.co/guide/en/elasticsearch/reference/6.8/_setting_up_a_new_policy.html

http://www.lryc.cn/news/360892.html

相关文章:

  • 【JavaScript脚本宇宙】揭秘HTTP请求库:深入理解它们的特性与应用
  • 【强化学习】DPO(Direct Preference Optimization)算法学习笔记
  • vue3 todolist 简单例子
  • Linux项目编程必备武器!
  • AndroidStudio编译很慢问题解决
  • PHAR反序列化
  • Rust安装
  • 513.找树左下角的值
  • docker基础,docker安装mysql,docker安装Nginx,docker安装mq,docker基础命令
  • MyBatis二、搭建 MyBatis
  • 昵称生成器
  • mysql仿照find_in_set写了一个replace_in_set函数,英文逗号拼接字符串指定替换
  • 机械设计手册第一册:公差
  • 如何把图片保存成16位png格式?
  • vue 关闭页面前释放资源
  • 堡垒机,日志审计系统,行为管理,漏洞扫描的作用
  • JVM学习-自定义类加载器
  • NDIS Filter开发-OID 请求
  • 软考 系统架构设计师之考试感悟2
  • [学习笔记](b站视频)PyTorch深度学习快速入门教程(绝对通俗易懂!)【小土堆】(ing)
  • Flutter开发效率提升1000%,Flutter Quick教程之定义构造参数和State成员变量
  • R语言数据分析-xgboost模型预测
  • 使用redis的setnx实现分布式锁
  • LangChain进行文本摘要 总结
  • 政安晨【零基础玩转各类开源AI项目】:解析开源项目的论文:Physical Non-inertial Poser (PNP)
  • 【机器学习】基于OpenCV和TensorFlow的MobileNetV2模型的物种识别与个体相似度分析
  • 建模杂谈系列244 TimeTraveller
  • 基于MingGW64 GCC编译Windows平台上的 libuvc
  • 【Linux】网络高级IO
  • 【C++ ——— 继承】