elasticsearch6.2.3 冷热架构设计

随着集群规模越来越大,有一些冷索引不需要经常移动分片,因此把冷索引单独存储在冷节点中,把热索引(最新添加的数据)存储在热节点中。

第一步 禁用rebalance

主要是为了防止集群中已有的索引 rebalance 到其他节点

PUT _cluster/settings
{
  "transient": {
    "cluster.routing.allocation.cluster_concurrent_rebalance":0
  }
}

第二步:给节点加标识:node.attr.box_type

关于 node.attr.box_type 属性介绍,可参考:enabling-awareness

修改hot节点的elasticsearch.yml配置文件,添加一行:

node.attr.box_type: hot

修改warm节点的elasticsearch.yml配置文件,添加一行:

node.attr.box_type: warm

第三步:定义通用的索引模板保证新创建索引的分片不会分配到warm节点上

当每月生成一个索引时,新建的索引,肯定是热索引,热索引的分片需要分配到hot节点上,不能分配到warm节点上。比如,loginmac-201908是新建的索引,其分配应该在hot节点上,假设只保留三个月的数据,那么 loginmac-201905就属于历史数据了,需要迁移到warm节点上去。

PUT /_template/hot_template
{
  "template": "*",
  "order": 0,
  "version": 0,
  "settings": {
    "index": {
      "routing": {
        "allocation": {
          "require": {
            "box_type": "hot"
          },
          "exclude":{
            "box_type": "warm"
          }
        }
      },
      "number_of_shards": 3,
      "number_of_replicas": 1,
      "refresh_interval": "50s"
    },
    "index.unassigned.node_left.delayed_timeout": "3d"
  }
}

关于index.routing.allocation.require和index.routing.allocation.exclude可参考:shard-allocation-filtering

第四步 把系统上已有索引的配置全部修改成hot配置

PUT _all/_settings
{
  "index": {
    "routing": {
      "allocation": {
        "require": {
          "box_type": "hot"
        }
      }
    }
  }
}

这是为了,保证当warm节点加入集群时,不要让热索引迁移到到warm节点上。

修改完重启es节点。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值