最详细的Codis集群扩容方法

来源:互联网 发布:淘宝货到付款流程 编辑:程序博客网 时间:2024/06/10 11:15
一、背景
当机器增加内存之后需要对紧张的codis集群容量进行扩容,针对codis集群的扩容一般采用增加新的redis实例,再将新的实例增加到新的group中,然后将group通过codis进行管理起来。
二、步骤
1、新增redis实例
原来是6381、6382、6383、6384这四个实例,现在增加6385和6386两个实例的配置文件,并且设置6385为master,6386为slave。配置如下图:
一路博客

其中6386配置了slaveof:
一路博客

2、启动新建的两个Redis
采用脚本来启动(startRedisByPort.sh):
#!/bin/sh
nohup ../bin/codis-server ./redis_conf/$1.conf &> /data/redis/logs/redis_$1.log &
一路博客
到此为止两个实例已经启动完成。

3、新建group3
进入dashboard的管理页面,点击“New Server Group”
一路博客

选择3,
一路博客 http://www.16boke.com

再添加redis实例
一路博客 http://www.16boke.com
输入:
一路博客 http://www.16boke.com

一路博客 http://www.16boke.com
注意:codis默认第一个添加的是master。

添加成功如图:
一路博客 http://www.16boke.com

4、开始数据迁移
一路博客 http://www.16boke.com

点击“Auto Rebalance”之后会自动开始迁移,管理页面会显示Migrate Task Info信息:
一路博客 http://www.16boke.com

5、迁移结束
一路博客 http://www.16boke.com
可以看到将之前每个实例中的key平均分配到新加之后的三个组中。

6、迁移时间
测试环境总key数为51141个,迁移总时间为22分钟左右,截取部分日志内容:
2016/02/25 11:38:52 rebalancer.go:113: [INFO] start rebalance
2016/02/25 11:38:54 rebalancer.go:135: [INFO] rebalance tasks submit finish
2016/02/25 11:38:54 migrate_task.go:135: [INFO] migration start: {SlotId:208 NewGroupId:3 Delay:0 CreateAt:1456371532 Percent:0 Status:pending Id:0000000000}
...
...
...
2016/02/25 12:00:15 migrate_task.go:145: [INFO] migration finished: {SlotId:941 NewGroupId:3 Delay:0 CreateAt:1456371534 Percent:0 Status:finished Id:0000000340}

转载来源:http://www.16boke.com/article/detail/82
0 0
原创粉丝点击