概述:

  1. 适合日志类型的数据存储方案。即当日数据写入,历史数据只读。
  2. 节省部分硬件成本。热数据采用更好的硬件。

环境:

已有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" # 标识为热数据节点

思路:

  1. 创建index模板,指定"index.routing.allocation.require.box_type"为"hot"。新建立的index默认放置在热数据节点中存储。
  2. 修改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数据冷热分离、数据冷备的更多相关文章

  1. 工作随笔—Elasticsearch大量数据提交优化

    问题:当有大量数据提交到Elasticsearch时,怎么优化处理效率? 回答: 批量提交 当有大量数据提交的时候,建议采用批量提交. 比如在做 ELK 过程中 ,Logstash indexer 提 ...

  2. 工作随笔——elasticsearch 6.6.1安装(docker-compose方式)

    docker-compose.yml: version: '2.2' services: es1: image: docker.elastic.co/elasticsearch/elasticsear ...

  3. Elasticsearch7.X ILM索引生命周期管理(冷热分离)

    Elasticsearch7.X ILM索引生命周期管理(冷热分离) 一.“索引生命周期管理”概述 Elasticsearch索引生命周期管理指:Elasticsearch从设置.创建.打开.关闭.删 ...

  4. es高级用法之冷热分离

    背景 用户需求:近期数据查询速度快,较远历史数据运行查询速度慢? 对于开发人员而言即数据的冷热分离,实现此功能有2个前提条件: 硬件:处理速度不同的硬件,最起码有读写速度不同的硬盘,如SSD.机械硬盘 ...

  5. ElasticStack系列之二十 & 数据均衡、迁移、冷热分离以及节点自动发现原理与机制

    1. 数据均衡 某个shard分配到哪个节点上,一般来说,是由 ELasticSearch 自行决定的.以下几种情况会触发分配动作: 新索引的建立 索引的删除 新增副本分片 节点增减引发的数据均衡 在 ...

  6. 用logstash,elasticSearch,kibana实现数据收集和统计分析工作

    原文链接:http://www.open-open.com/lib/view/open1448799635720.html 世界上的软件80%是运行在内网的,为了使得运行在客户端的软件有良好的体验,并 ...

  7. Elasticsearch使用小结之冷热分离

    Elasticsearch使用小结之冷热分离 索引迁移 索引setting中的index.routing.allocation.exclude和index.routing.allocation.inc ...

  8. ElasticSearch实战系列十: ElasticSearch冷热分离架构

    前言 本文主要介绍ElasticSearch冷热分离架构以及实现. 冷热分离架构介绍 冷热分离是目前ES非常火的一个架构,它充分的利用的集群机器的优劣来实现资源的调度分配.ES集群的索引写入及查询速度 ...

  9. 让Elasticsearch集群冷热分离、读写分离【转】

    转自:https://blog.csdn.net/jiao_fuyou/article/details/50511255 根据Elasticsearch中文社区<ES冷热分离(读写分离) hot ...

随机推荐

  1. 基于tomcat的solr环境搭建(Linux)

    ♥♥  solr是基于lucene的一个全文检索服务器,提供了一些类似webservice的API接口,用户可以通过http请求solr服务器,进行索引的建立和索引的搜索.索引建立的过程:用户提交的文 ...

  2. tolua杂记

    1 字符串调用luaFunc  :DoString public class CallLuaFunction : MonoBehaviour { private string script = @&q ...

  3. SPOJ - NSUBSTR(长度为1-len的字串出现的最大次数

    题意:给你一个字符串,要你输出1-len的字串出现的最大次数. /** @xigua */ #include <stdio.h> #include <cmath> #inclu ...

  4. 存储引擎中MYIASM是什么意思

  5. LINUX系统下MySQL 压力测试工具super smack

    摘要:1.源文件下载地址:http://vegan.net/tony/supersmack/2.安装:注意在编译时,可以先把对应的libmysqlclient.so.*拷贝到/usr/lib3.测试: ...

  6. 2018.10.26 bzoj2721: [Violet 5]樱花(数论)

    传送门 推一波式子: 1x+1y=1n!\frac 1 x+\frac 1 y=\frac 1 {n!}x1​+y1​=n!1​ =>xy−x∗n!−y∗n!xy-x*n!-y*n!xy−x∗n ...

  7. java Concurrent包学习笔记(三):ReentrantLock

    一.可重入性的理解 从名字上理解,ReenTrantLock的字面意思就是再进入的锁,其实synchronized关键字所使用的锁也是可重入的,两者关于这个的区别不大.两者都是同一个线程每进入一次,锁 ...

  8. identify.class.php<======>token加密方法

    class Identify { static private $cert = "1111111"; static public function writeSecret($mob ...

  9. Atcoder Regular-074 Writeup

    C - Chocolate Bar 题面 There is a bar of chocolate with a height of H blocks and a width of W blocks. ...

  10. (转)ASP.NET(C#)FileUpload实现上传限定类型和大小的文件到服务器

    上传文件有两个主要的目的地,一个是服务器,另一个是数据库,ASP.NET内置了FileUpload这个上传控件,文本框显示用户选择的文件的全名. 其属性主要包括: ContenLength:上传文件大 ...