15.redis集群的扩容|缩容步骤概括

1.redis扩容的话,首先创建redis-cluster节点(具体配置和其他节点一样),然后再把他们加入到redis集群中 

redis-cli --cluster add-node  new_host_ip:port  exsitint_host_ip:port                      ##这个是将新节点加入到集群中
redis-cli --cluster add-node  new_host_ip:port  exsitint_host_ip:port   --cluster-slave    ##这个将新节点加入集群中作为后面一个节点的从节点

2.迁移槽,迁移槽时要计算原节点迁移多个槽到新节点中

redis-cli --cluster reshard <host>:<port> --cluster-from <node-id> --cluster-to <node-id> --cluster-slots <number of slots> --cluster-yes

##
<host>:<port>:可以指定任意一个在集群中的节点
## --cluster-from:这个指的是原节点
## --cluter-to:这个指的是目标节点
## --cluter-slots:这个是要迁移的槽的数量

3.迁移完了之后,最后可以rebalance一下

4.缩容的话(感觉这种操作可能很少),首先也需要用2中的命令将槽给迁移到其他节点上,然后再用redis-cli --cluter del-node  run_id  进行删除.

 

posted on 2022-11-26 12:37  太白金星有点烦  阅读(990)  评论(0)    收藏  举报

导航