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

你可能感兴趣的:(Elasticsearch)