Elasticsearch集群冷热分离-实际操作

       两台物理机(40core,128G内存, 1T ssd, 1T*3 hdd),每台机器同时部署一个hot node和cold node,共4个node。hot node使用ssd作为存储介质,分配32G内存,接收实时日志。cold node使用hdd盘作为存储介质,分配16G内存,存储历史日志(只读不写)。每日固定时间进行热->冷迁移。 

节点级别配置

在 hot 组的两个节点的 elasticsearch.yml 配置文件 Node 配置段中增加

node.tag: hot

在 cold 组的两个节点的 elasticsearch.yml 配置文件 Node 配置段中增加

node.tag: cold

索引级别配置

       为了让新建的的索引自动分配到 hot 节点,在 template 中增加索引的分配规则,如所有 logstash* 的索引匹配的模板叫 logstash ,在 logstash 模板下增加:

PUT /_template/logstash
{
        "order": 0,
        "template": "logstash*",
        "settings": {
            "index.routing.allocation.include.tag": "hot",
            "index.refresh_interval": "30s",
            "index.number_of_replicas": "1",
            "index.number_of_shards": "1",
            "index.translog.flush_threshold_ops": "30000"
        }
} 

“index.routing.allocation.include.tag”: “hot”,表示新建索引将分配到 node.tag = hot 的节点下

 

定时任务将历史索引分配到 cold 节点下

  • elasticsearch 1.4 安装 curator 3.5 脚本,每天4点将历史索引分配到 cold 节点下
pip install elasticsearch-curator==3.5
  • 将40天以前的 logstash* 索引分配到 cold 节点下
curator allocation --rule tag=cold --type include indices --time-unit days --older-than 40  --timestring '%Y.%m.%d' --prefix logstash
  • 将400天以前的 ocslog*,ocscdr* 索引分配到 cold 节点下
curator allocation --rule tag=cold --type include indices --time-unit days --older-than 400 --timestring '%Y.%m.%d' --prefix ocslog
curator allocation --rule tag=cold --type include indices --time-unit days --older-than 400 --timestring '%Y.%m.%d' --prefix ocscdr

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值