[elk]-elasticsearch 实现冷热隔离

elasticsearch 实现冷热隔离

前言

冷数据索引:查询频率低,基本无写入,一般为当天或最近2天以前的数据索引

热数据索引:查询频率高,写入压力大,一般为当天数据索引

优点

1冷热数据分离

ES集群的索引写入及查询速度主要依赖于磁盘的IO速度,冷热数据分离的关键为使用SSD磁盘存储数据。

若全部使用SSD,成本过高,且存放冷数据较为浪费,因而使用普通SATA磁盘与SSD磁盘混搭,可做到资源充分利用,性能大幅提升的目标。

2 数据读写分离

几点结论:

若使当天索引及副本都写在SSD磁盘上,SSD磁盘使用量需翻倍,代价可能过高。(读写效率最高,但由于SSD节点肯定较少,读写都在相同节点上,节点压力会非常大)

现有的方式,只使用普通的SATA磁盘存储,代价最低。(读写效率最低,即为当前运行状况)

使用集群路由分配策略,SSD与SATA各存放1份数据,SSD磁盘只需分配原先的一半。(读写效率折中,均有较大提升)

 

先安装es集群

我以elasticsearch-6.3.2.tar.gz为例,

各节点的es配置

172.16.129.8  master

172.16.128.244 cold

172.16.128.174  hot

master

cluster.name: elk

node.master: true

node.data: false

node.name: 172.16.129.8

#node.attr.box_type: hot

#node.tag: hot

path.data: /usr/local/elasticsearch-6.3.2/data

path.logs:  /usr/local/elasticsearch-6.3.2/log

network.host: 0.0.0.0

http.port: 9200

transport.tcp.port: 9300

transport.tcp.compress: true

discovery.zen.ping.unicast.hosts: ["172.16.129.8"]

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节点

cluster.name: elk

node.master: false

node.data: true

node.name: 172.16.128.174

node.attr.box_type: hot

path.data: /usr/local/elasticsearch-6.3.2/data

path.logs:  /usr/local/elasticsearch-6.3.2/log

network.host: 0.0.0.0

http.port: 9200

transport.tcp.port: 9300

transport.tcp.compress: true

discovery.zen.ping.unicast.hosts: ["172.16.129.8"]

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节点

cluster.name: elk

node.master: false

node.data: true

node.name: 172.16.128.244

node.attr.box_type: cold

path.data: /usr/local/elasticsearch-6.3.2/data

path.logs:  /usr/local/elasticsearch-6.3.2/log

network.host: 0.0.0.0

http.port: 9200

transport.tcp.port: 9300

transport.tcp.compress: true

discovery.zen.ping.unicast.hosts: ["172.16.129.8"]

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: "*"

 

启动es之后  启动filebeat将日志导入es

通过header查看 发现数据显示的不对

删除索引

通过kibana 执行如下命令

或者curl命令如下

curl -XPUT "http://172.16.129.8:9200/tomcat-test-2019.02.02/_settings" -H 'Content-Type: application/json' -d'

{

  "settings": {

    "index.routing.allocation.require.box_type": "cold"

  }

}'

再次启动filebeat

查看es日志  日志存在于hot 节点上

 

测试是否可以将hot节点的数据 迁移到cold上

执行

或者

curl -XPUT "http://172.16.129.8:9200/tomcat-test-2019.02.02/_settings" -H 'Content-Type: application/json' -d'

{

  "settings": {

    "index.routing.allocation.require.box_type": "cold"

  }

}'

迁移成功

后来生成新的索引 还是会在hot节点

 

参考

http://www.mamicode.com/info-detail-2361555.html

https://elasticsearch.cn/article/6127

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爷来辣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值