本文以最新的elasticsearch-6.3.0.tar.gz为例,为了节约资源,本文将副本调为0, 无client角色

https://www.elastic.co/blog/hot-warm-architecture-in-elasticsearch-5-x

以前es2.x版本配置elasticsearch.yml 里的node.tag: hot这个配置不生效了

被改成了这个
node.attr.box_type: hot

es架构

各节点的es配置

master节点:
[root@n1 ~]# cat /usr/local/elasticsearch/config/elasticsearch.yml
cluster.name: elk
node.master: true
node.data: false
node.name: 192.168.2.11
#node.attr.box_type: hot
#node.tag: hot
path.data: /data/es
path.logs: /data/log
network.host: 192.168.2.11
http.port: 9200
transport.tcp.port: 9300
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["192.168.2.11"]
cluster.routing.allocation.disk.watermark.low: 85%
cluster.routing.allocation.disk.watermark.high: 90%
indices.fielddata.cache.size: 10%
indices.breaker.fielddata.limit: 30%
http.cors.enabled: true
http.cors.allow-origin: "*"
- client节点(这里就不配置了)

node.master: false
node.data: false
- hot节点
[root@n2 ~]# cat /usr/local/elasticsearch/config/elasticsearch.yml
cluster.name: elk
node.master: false
node.data: true
node.name: 192.168.2.12
node.attr.box_type: hot
path.data: /data/es
network.host: 192.168.2.12
http.port: 9200
transport.tcp.port: 9300
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["192.168.2.11"]
cluster.routing.allocation.disk.watermark.low: 85%
cluster.routing.allocation.disk.watermark.high: 90%
indices.fielddata.cache.size: 10%
indices.breaker.fielddata.limit: 30%
http.cors.enabled: true
http.cors.allow-origin: "*"
- cold节点
[root@n3 ~]# cat /usr/local/elasticsearch/config/elasticsearch.yml
cluster.name: elk
node.master: false
node.data: true
node.name: 192.168.2.13
node.attr.box_type: cold
path.data: /data/es
network.host: 192.168.2.13
http.port: 9200
transport.tcp.port: 9300
transport.tcp.compress: true
discovery.zen.ping.unicast.hosts: ["192.168.2.11"]
cluster.routing.allocation.disk.watermark.low: 85%
cluster.routing.allocation.disk.watermark.high: 90%
indices.fielddata.cache.size: 10%
indices.breaker.fielddata.limit: 30%
http.cors.enabled: true
http.cors.allow-origin: "*"

如何实现某索引数据写到指定的node?(根据节点tag即可)

我hot节点打了tag

node.attr.box_type: cold
创建一个template(这里我用kibana来操作es的api)

PUT _template/test
{
"index_patterns": "test-*",
"settings": {
"index.number_of_replicas": "0",
"index.routing.allocation.require.box_type": "hot"
}
}

意思是test-*索引命名的,都将其数据放到hot节点上.

如何实现数据从hot节点迁移到老的cold节点?

以test-2018.07.05索引为例,将它从hot节点迁移到cold节点

kibana里操作:

PUT /test-2018.07.05/_settings
{
"settings": {
"index.routing.allocation.require.box_type": "cold"
}
}

生产中可能每天,或每h,生成一个index.

test-2018.07.01
test-2018.07.02
test-2018.07.03
test-2018.07.04
test-2018.07.05
...

我可以写一个sh定时任务,每天晚上定时迁移数据.

如我在hot节点只保留7天的数据,7天以前的索引我匹配到, 每天晚上执行以下迁移命令即可.

cold节点数据保留1个月?

https://www.cnblogs.com/iiiiher/p/8029062.html

优化点:

1.为了提高吞吐量

path.data:/data1,/data2,/data3,/data4,/data5 可以每个目录挂一块盘

2.如果有10台hot节点,可以设置10个shards

logstash测试

input { stdin { } }
output {
elasticsearch {
index => "test-%{+YYYY.MM.dd}"
hosts => ["192.168.2.11:9200"]
}
stdout {codec => rubydebug}
} /usr/local/logstash/bin/logstash -f logstash.yaml --config.reload.automatic

关于es的index template

关于es的template

es数据入库时候都会匹配一个index template,默认匹配的是logstash这个template

template大致分成setting和mappings两部分

  1. settings主要作用于index的一些相关配置信息,如分片数、副本数,tranlog同步条件、refresh等。
  2. mappings主要是一些说明信息,大致又分为_all、_source、prpperties这三部分: https://elasticsearch.cn/article/335

根据index name来匹配使用哪个index template. index template属于节点范围,而非全局. 需要给某个节点单独设置index_template(如给设置一些特有的tag).

[elk]elasticsearch实现冷热数据分离的更多相关文章

  1. ELK冷热数据分离

      通常情况下,我们使用ELK日志分析平台最常用的数据时间为1周或一个月(因业务场景不同,可能存在差别),时间比较长的数据没有特殊情况可能我们就没有必要再进行查询了,但是因业务需求或者作为凭证,这些日 ...

  2. EFK教程(3) - ElasticSearch冷热数据分离

    基于ElasticSearch多实例架构,实现资源合理分配.冷热数据分离 作者:"发颠的小狼",欢迎转载与投稿 目录 ▪ 用途 ▪ 架构 ▪ 192.168.1.51 elasti ...

  3. 分布式mysql 和 zk ( zookeeper )的分布式的区别 含冷热数据讨论

    zk ( zookeeper )的分布式仅仅指的是备份模式. 分布式 mysql 不仅仅要关注备份(从以往的半主,主主,到 paxos). (mysql 比 hbase 的region成熟, hdfs ...

  4. 使用ELK(Elasticsearch + Logstash + Kibana) 搭建日志集中分析平台实践--转载

    原文地址:https://wsgzao.github.io/post/elk/ 另外可以参考:https://www.digitalocean.com/community/tutorials/how- ...

  5. ELk(Elasticsearch, Logstash, Kibana)的安装配置

    目录 ELk(Elasticsearch, Logstash, Kibana)的安装配置 1. Elasticsearch的安装-官网 2. Kibana的安装配置-官网 3. Logstash的安装 ...

  6. ELK(elasticsearch+kibana+logstash)搜索引擎(二): elasticsearch基础教程

    1.elasticsearch的结构 首先elasticsearch目前的结构为 /index/type/id  id对应的就是存储的文档ID,elasticsearch一般将数据以JSON格式存储. ...

  7. ElasticSearch5.X的冷热数据架构

    转载:https://my.oschina.net/xiaomaijiang/blog/826701 当使用ElasticSearch做大规模的时序数据分析的时候,我们建议使用基于时序的索引并且采用3 ...

  8. CentOS 6.x ELK(Elasticsearch+Logstash+Kibana)

    CentOS 6.x ELK(Elasticsearch+Logstash+Kibana) 前言 Elasticsearch + Logstash + Kibana(ELK)是一套开源的日志管理方案, ...

  9. ELK(elasticsearch+logstash+kibana)入门到熟练-从0开始搭建日志分析系统教程

    #此文篇幅较长,涵盖了elk从搭建到运行的知识,看此文档,你需要会点linux,还要看得懂点正则表达式,还有一个聪明的大脑,如果你没有漏掉步骤的话,还搭建不起来elk,你来打我. ELK使用elast ...

随机推荐

  1. 读取XML文件内容

    myeclipse中类的格式 上面中的RunMain.java为程序执行的入口,JdbcUtil.java为实体类,XmlDocumentUtil.java执行解释xml文件与获取里面的属性,程序所需 ...

  2. NIO编程---通道(Channel)

    **版权声明:本文为小斑马伟原创文章,转载请注明出处! 通道(Channel):由java.nio.channels 包定义的.Channel 表示IO 源与目标打开的连接.Channel 类似于传统 ...

  3. Callable与Runable接口 submit与execute区别

    execute(Runnable x) 没有返回值.可以执行任务,但无法判断任务是否成功完成. submit(Runnable x) 返回一个future.可以用这个future来判断任务是否成功完成 ...

  4. Spring里的applicationContext.getBeansWithAnnotation

    getBeansWithAnnotation Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation ...

  5. DataGrid绑定DataTable出错

    直接用DataGrid.ItemSource = DataTable.DefaultView时会出现以下错误: target element is 'TextBlock' (Name=''); tar ...

  6. CODEVS 1074 食物链 2001年NOI全国竞赛(洛谷 P2024)

    题目描述 Description 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形.A吃B,B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并 ...

  7. STM32(HY-SRF05)超声波测距项目

    参考资料: https://www.cnblogs.com/qsyll0916/p/6964638.html http://blog.csdn.net/zhangdaxia2/article/deta ...

  8. 编程菜鸟的日记-初学尝试编程-编写函数实现strcmp功能

    #include <iostream>using namespace std;int mystrcmp(const char *str1,const char *str2){ assert ...

  9. 1. cs231n k近邻和线性分类器 Image Classification

    第一节课大部分都是废话.第二节课的前面也都是废话. First classifier: Nearest Neighbor Classifier 在一定时间,我记住了输入的所有的图片.在再次输入一个图片 ...

  10. 4989: [Usaco2017 Feb]Why Did the Cow Cross the Road

    题面:4989: [Usaco2017 Feb]Why Did the Cow Cross the Road 连接 http://www.lydsy.com/JudgeOnline/problem.p ...