沪ICP备2021032517号-1

Elasticsearch 冷热分离

  |   0 评论   |   0 浏览

Master配置

cluster.name: es-cluster
path.data: /data/es
node.master: true
node.data: false
node.ingest: false
path.logs: /var/log/elasticsearch
indices.memory.index_buffer_size: 15%
thread_pool.bulk.queue_size: 1024
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["10.10.4.15","10.10.4.6","10.10.4.47"]

Hot节点配置

cluster.name: es-cluster
path.data: /data/es
node.master: false
node.data: true
node.ingest: false
node.attr.box_type: "hot"
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
indices.memory.index_buffer_size: 35%
thread_pool.bulk.queue_size: 1024
discovery.zen.ping.unicast.hosts: ["10.10.4.15","10.10.4.6","10.10.4.47"]

Cool节点配置

cluster.name: es-cluster
path.data: /data/es
node.master: false
node.data: true
node.ingest: false
path.logs: /var/log/elasticsearch
network.host: 10.10.4.35
node.attr.box_type: "cool"
indices.memory.index_buffer_size: 15%
thread_pool.bulk.queue_size: 1024
discovery.zen.ping.unicast.hosts: ["10.10.4.15","10.10.4.6","10.10.4.47"]

冷热数据迁移任务计划

给新生成的索引默认加上“hot”的标签

curl -XPUT http://10.10.2.46:9200/_template/hot-template -H 'Content-Type: application/json' -d '{"index_patterns" : "*", "order" : 0, "settings" : {"index.routing.allocation.require.box_type": "hot"}}'

设置脚本自动将前一天按天创建的索引标记为cool

#!/bin/bash
YESTERDAY=`date -d 'yesterday' '+%Y%m%d'`
LAST_MONTH=`date -d "last month" '+%Y%m'`
INDEX=`date -d '3 days ago' '+%Y%m%d'`

curl -XPUT "http://10.10.4.46:9200/*-$YESTERDAY/_settings"  -H 'Content-Type: application/json' -d '{"index.routing.allocation.require.box_type": "cool"}'
curl -XPUT "http://10.10.4.46:9200/*-$LAST_MONTH/_settings"  -H 'Content-Type: application/json' -d '{"index.routing.allocation.require.box_type": "cool"}'
curl -XDELETE "http://10.10.4.46:9200/*-$INDEX"

标题:Elasticsearch 冷热分离
作者:zifuy
地址:https://www.zifuy.cn/articles/2021/09/22/1632276929030.html