工作随笔——elasticsearch数据冷热分离、数据冷备
概述:
- 适合日志类型的数据存储方案。即当日数据写入,历史数据只读。
- 节省部分硬件成本。热数据采用更好的硬件。
环境:
已有6个ES节点,使用docker-compose方式搭建。
es1:master节点
# elasticsearch.yml
node.name: "es1"
cluster.name: "docker-cluster"
network.host: 0.0.0.0
node.master: true
node.data: false
es2、es3、es4 热数据节点
# elasticsearch.yml
node.name: "es2" # 提示:自行修改其他节点的名称
cluster.name: "docker-cluster"
network.host: 0.0.0.0
node.master: false
node.data: true
discovery.zen.ping.unicast.hosts: ["es1"]
node.attr.box_type: "hot" # 标识为热数据节点
es5、es6 冷数据节点
# elasticsearch.yml
node.name: "es5-cool" # 提示:自行修改其他节点的名称
cluster.name: "docker-cluster"
network.host: 0.0.0.0
node.master: false
node.data: true
discovery.zen.ping.unicast.hosts: ["es1"]
node.attr.box_type: "cool" # 标识为热数据节点
思路:
- 创建index模板,指定"index.routing.allocation.require.box_type"为"hot"。新建立的index默认放置在热数据节点中存储。
- 修改index中"index.routing.allocation.require.box_type"为"cool",让ES自动迁移数据到冷数据节点中存储。
创建index模板:
PUT /_template/hot_template
{
"index_patterns" : "*", # 匹配所有的索引
"order" : , # 多个模板同时匹配,以order顺序倒排,order越大,优先级越高
"settings" : {
"number_of_shards" : ,
"index.routing.allocation.require.box_type": "hot", # 指定默认为热数据节点
"number_of_replicas":
}
}
提示:如果不想创建index模板,可以在创建index时在setting中指定 "index.routing.allocation.require.box_type": "hot" 配置,效果相同。
创建测试index:
POST /test_index/test
{
"test": "test"
}
查看测试index的settings信息:
GET test_index/_settings
回显如下:
{
"test_index" : {
"settings" : {
"index" : {
"routing" : {
"allocation" : {
"require" : {
"box_type" : "hot" # 默认index模板匹配成功,数据存放在热数据节点
}
}
},
"number_of_shards" : "",
"provided_name" : "test_index",
"creation_date" : "",
"number_of_replicas" : "",
"uuid" : "1q0SM1znRUKknJV6N8iJDQ",
"version" : {
"created" : ""
}
}
}
}
}
数据迁移:
PUT test_index/_settings
{
"settings": {
"index.routing.allocation.require.box_type": "cool" # 指定数据存放到冷数据节点
}
}
ES会自动将 test_index 的数据迁移到冷数据节点上。
提示:更新索引标记的任务可以放到定时任务中去实现。
1. 有x台机器tag设置为hot
2. 有y台机器tag设置为cool
3. hot集群中只存最近两天的.
4. 有一个定时任务每天将前一天的索引标记为cool
5. es看到有新的标记就会将这个索引迁移到冷集群中, 这都是es自动完成的
参考:
https://elasticsearch.cn/article/6127
https://elasticsearch.cn/question/283
数据冷备:
参考:https://www.elastic.co/guide/cn/elasticsearch/guide/current/backing-up-your-cluster.html
PUT _snapshot/my_backup # my_backup 备份的名称
{
"type": "fs",
"settings": {
"location": "/mount/backups/my_backup"
}
}
ES一旦数据被删除无法通过translog进行数据恢复,所以一定要进行数据冷备。
工作随笔——elasticsearch数据冷热分离、数据冷备的更多相关文章
- 工作随笔—Elasticsearch大量数据提交优化
问题:当有大量数据提交到Elasticsearch时,怎么优化处理效率? 回答: 批量提交 当有大量数据提交的时候,建议采用批量提交. 比如在做 ELK 过程中 ,Logstash indexer 提 ...
- 工作随笔——elasticsearch 6.6.1安装(docker-compose方式)
docker-compose.yml: version: '2.2' services: es1: image: docker.elastic.co/elasticsearch/elasticsear ...
- Elasticsearch7.X ILM索引生命周期管理(冷热分离)
Elasticsearch7.X ILM索引生命周期管理(冷热分离) 一.“索引生命周期管理”概述 Elasticsearch索引生命周期管理指:Elasticsearch从设置.创建.打开.关闭.删 ...
- es高级用法之冷热分离
背景 用户需求:近期数据查询速度快,较远历史数据运行查询速度慢? 对于开发人员而言即数据的冷热分离,实现此功能有2个前提条件: 硬件:处理速度不同的硬件,最起码有读写速度不同的硬盘,如SSD.机械硬盘 ...
- ElasticStack系列之二十 & 数据均衡、迁移、冷热分离以及节点自动发现原理与机制
1. 数据均衡 某个shard分配到哪个节点上,一般来说,是由 ELasticSearch 自行决定的.以下几种情况会触发分配动作: 新索引的建立 索引的删除 新增副本分片 节点增减引发的数据均衡 在 ...
- 用logstash,elasticSearch,kibana实现数据收集和统计分析工作
原文链接:http://www.open-open.com/lib/view/open1448799635720.html 世界上的软件80%是运行在内网的,为了使得运行在客户端的软件有良好的体验,并 ...
- Elasticsearch使用小结之冷热分离
Elasticsearch使用小结之冷热分离 索引迁移 索引setting中的index.routing.allocation.exclude和index.routing.allocation.inc ...
- ElasticSearch实战系列十: ElasticSearch冷热分离架构
前言 本文主要介绍ElasticSearch冷热分离架构以及实现. 冷热分离架构介绍 冷热分离是目前ES非常火的一个架构,它充分的利用的集群机器的优劣来实现资源的调度分配.ES集群的索引写入及查询速度 ...
- 让Elasticsearch集群冷热分离、读写分离【转】
转自:https://blog.csdn.net/jiao_fuyou/article/details/50511255 根据Elasticsearch中文社区<ES冷热分离(读写分离) hot ...
随机推荐
- [SoapUI] 在SoapUI中通过Groovy脚本执行window命令杀掉进程
//杀Excel进程 String line def p = "taskkill /F /IM EXCEL.exe".execute() def bri = new Buffere ...
- Android Studio 小新兵
1. java.lang.IllegalStateException: This app has been built with an incorrect configuration. Please ...
- Aspose.Words给word文档加水印
需求:在一些重要的Word文档需要打印时,添加水印以明出处. 方案:使用Aspose组件给word文档 代码:干货如下 /// <summary> /// Inserts a waterm ...
- java Mather 的 group 含义
参考博文: http://blog.csdn.net/java2king/article/details/4395067 明白了group 的 含义 public class Test { pub ...
- Windows-universal-samples学习笔记系列二:Controls, layout, and text
Controls, layout, and text AutoSuggestBox migration Clipboard Commanding Context menu Context menu ( ...
- BP神经网络的参数改进参考?
参考文献:黄巧巧. 基于BP神经网络的手写数字识别系统研究[D].华中师范大学,2009. 47-52 BP神经网络的缺陷:收敛速度慢和局部极小点的问题 使用的改进方案有 1. 学习速率(learn ...
- chattr改变文件属性
Linux chattr命令用于改变文件属性. 这项指令可改变存放在ext2文件系统上的文件或目录属性,这些属性共有以下8种模式: a:让文件或目录仅供附加用途. b:不更新文件或目录的最后存取时间. ...
- 2019.01.22 uoj#14. 【UER #1】DZY Loves Graph(并查集)
传送门 题意简述: 要求支持以下操作: 在a与b之间连一条长度为i的边(i是操作编号):删除当前图中边权最大的k条边:表示撤销第 i−1次操作,保证第1次,第i−1 次不是撤回操作. 要求在每次操作后 ...
- 2018.10.29 洛谷P4129 [SHOI2006]仙人掌(仙人掌+高精度)
传送门 显然求出每一个环的大小. Ans=∏i(siz[i]+1)Ans=\prod_i(siz[i]+1)Ans=∏i(siz[i]+1) 注意用高精度存答案. 代码: #include<b ...
- SimpleDateFormat转换时间,12,24时间格式[转]
SimpleDateFormat转换时间,12,24时间格式 来自:http://blog.csdn.net/dongguang1082/article/details/4387165 在使用Simp ...