elasticsearch集群更换节点操作


在elasticsearch集群中,由于在原有服务器集群上,每台服务器开了3个实例,导致部分节点压力过大,因此,新增一台服务器,将原有节点迁移到新服务器。
elasticsearch集群中增加节点步骤:

1.关闭集群分配reblance配置

PUT _cluster/settings 
{
  "transient": {
    "cluster.routing.rebalance.enable":"none"
  }
}

结果:

{
  "acknowledged": true,
  "persistent": {},
  "transient": {
    "cluster": {
      "routing": {
        "rebalance": {
          "enable": "none"
        }
      }
    }
  }
}

此时,索引的变更不再会导致分片在节点中的迁移。
如果需要更合理的管理es集群,建议将集群reblance关闭,完全手动管理,这样效率会更高,但是需要更加复杂的脚本配合。

2.增加节点

vim /etc/security/limits.conf
增加如下内容:

elastic soft memlock unlimited
elastic hard memlock unlimited
elastic soft nofile  655350
elastic hard nofile  655350
elastic soft nproc   655350
elastic soft nproc   655350

vim /etc/sysctl.conf
增加

vm.max_map_count = 262144
sysctl -p

创建用户

useradd elasticsearch -d  /opt/elasticsearch

修改hosts文件,确保本机hostname在 hosts文件中有描述

切换到elastic用户

unzip elasticsearch-5.0.1.zip 
mv ./elasticsearch-5.0.1 ./elasticsearch-node5-1
ln -s /opt/elasticsearch/elasticsearch-node5-1 /opt/elasticsearch/node5-1

修改 /opt/elasticsearch/node5/config 下的jvm.options
将内存改为20G
-Xms20g
-Xmx20g

安装xpack
./bin/elasticsearch-plugin install file:///opt/elasticsearch/x-pack-5.0.1.zip
增加node,group配置
修改
elasticsearch.yml
cluster.routing.allocation.awareness.attributes: rack
node.attr.rack: r3
这样可以避免统一索引的分片备份到相同节点

启动节点:

 /opt/elasticsearch/node5-1/bin/elasticsearch -d

此时通过elk监控界面可以看到新增加的节点
image.png

3.reroute 节点数据

采用如下命令即可

POST _cluster/reroute
{
  "commands":[
    {
     "move" : {
                "index" : "activemq-2017.11.01", "shard" : 2,
                "from_node" : "node4-3", "to_node" : "node5-1"
      }
    },
       {
         "move" : {
                "index" : "activemq-2017.11.01", "shard" : 3,
                "from_node" : "node4-3", "to_node" : "node5-1"
         }
       },
       {
         "move" : {
                "index" : "activemq-2017.11.01", "shard" : 4,
                "from_node" : "node4-3", "to_node" : "node5-1"
         }
       }
    ]
}

image.png

重复上述操作,将需要迁移的节点上的shard全部迁移到新节点,之后关闭节点,并重新打开自动平衡即可。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值