Redis Cluster在线迁移
由于之前的redis cluster物理硬件性能不足。决定升级到更好的服务器上。
考虑到redis是核心生产数据库,决定在线迁移,迁移过程,不中断服务。
下面是测试环境的完成迁移步骤:
1. 原环境(测试环境,没有创建slave)
10.21.14.251:7000
10.21.14.251:7001
10.21.14.251:7002
2. 在新主机上,启动三个redis实例
10.21.10.120:7000
10.21.10.120:7001
10.21.10.120:7002
3. 将三个redis,都添加到集群中. 命令格式redis-trib.rb add-node <新增节点名> < 原集群节点名>
./redis-trib.rb add-node 10.21.10.120:7000 10.21.14.251:7000
./redis-trib.rb add-node 10.21.10.120:7001 10.21.14.251:7000
./redis-trib.rb add-node 10.21.10.120:7002 10.21.14.251:7000
4. 确认添加成功之后,开始reshard slot
./redis-trib.rb reshard 10.21.10.120:7000
5. 遇到点问题,由于网络超时等原因,导致resharding中断。然后出现两边都有slot的情况,需要通过fix的方式来修复
[redis@ip-10-21-14-251 redis]$ ./redis-trib.rb reshard 10.21.10.120:7000
>>> Performing Cluster Check (using node 10.21.10.120:7000)
M: 4422ab38377fa8828e0f7884570b3b482a66496b 10.21.10.120:7000
slots:5026-5460 (435 slots) master
0 additional replica(s)
M: 5b38e63a1091baa3a871a52275489a2aa1d28bfb 10.21.10.120:7002
slots:894-3397 (2504 slots) master
0 additional replica(s)
M: bb1572074d41254e5b4d5aae5c52e54f5129d6d5 10.21.14.251:7001
slots:3398-4999,5461-15922 (12064 slots) master
0 additional replica(s)
M: 396a7fbd2ec61752f9e848a1d8cc7b405aef0356 10.21.14.251:7000
slots: (0 slots) master
0 additional replica(s)
M: 9f215e7e4b511f3d2bbf5d734731899b71a62a3b 10.21.10.120:7001
slots:0-893,5000-5025,15923-15948 (946 slots) master
0 additional replica(s)
M: 0c9b383f65ae4fefc5e02617fb76a845d7510a53 10.21.14.251:7002
slots:15949-16383 (435 slots) master
0 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
[WARNING] Node 10.21.10.120:7002 has slots in importing state (3398).
[WARNING] Node 10.21.14.251:7001 has slots in migrating state (3398).
[WARNING] The following slots are open: 3398
>>> Check slots coverage...
[OK] All 16384 slots covered.
*** Please fix your cluster problems before resharding <<<<<<<<<<<<<<<<<<<<<
6. 可以使用下面命令进行集群检查
./redis-trib.rb check 10.21.10.120:7000
7. 执行下面命令进行修复,然后就可以继续reshard slot了
./redis-trib.rb fix 10.21.10.120:7000
8. 全部slot迁移完成
$ ./redis-trib.rb check 10.21.10.120:7000
>>> Performing Cluster Check (using node 10.21.10.120:7000)
M: 4422ab38377fa8828e0f7884570b3b482a66496b 10.21.10.120:7000
slots:3399-4999,5026-7332 (3908 slots) master
0 additional replica(s)
M: 5b38e63a1091baa3a871a52275489a2aa1d28bfb 10.21.10.120:7002
slots:894-3398,7333-15332,15949-16383 (10940 slots) master
0 additional replica(s)
M: bb1572074d41254e5b4d5aae5c52e54f5129d6d5 10.21.14.251:7001
slots: (0 slots) master
0 additional replica(s)
M: 396a7fbd2ec61752f9e848a1d8cc7b405aef0356 10.21.14.251:7000
slots: (0 slots) master
0 additional replica(s)
M: 9f215e7e4b511f3d2bbf5d734731899b71a62a3b 10.21.10.120:7001
slots:0-893,5000-5025,15333-15948 (1536 slots) master
0 additional replica(s)
M: 0c9b383f65ae4fefc5e02617fb76a845d7510a53 10.21.14.251:7002
slots: (0 slots) master
0 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
确认一下状态
[redis@ip-10-21-14-251 redis]$ ./redis-cli -p 7000 cluster nodes
bb1572074d41254e5b4d5aae5c52e54f5129d6d5 10.21.14.251:7001 master - 0 1509611814919 6 connected
9f215e7e4b511f3d2bbf5d734731899b71a62a3b 10.21.10.120:7001 master - 0 1509611811917 14 connected 0-893 5000-5025 15333-15948
5b38e63a1091baa3a871a52275489a2aa1d28bfb 10.21.10.120:7002 master - 0 1509611815923 13 connected 894-3398 7333-15332 15949-16383
396a7fbd2ec61752f9e848a1d8cc7b405aef0356 10.21.14.251:7000 myself,master - 0 0 1 connected
4422ab38377fa8828e0f7884570b3b482a66496b 10.21.10.120:7000 master - 0 1509611813919 12 connected 3399-4999 5026-7332
0c9b383f65ae4fefc5e02617fb76a845d7510a53 10.21.14.251:7002 master - 0 1509611812917 3 connected
9. 确认状态OK的话,开始删除节点
./redis-trib.rb del-node 10.21.14.251:7000 396a7fbd2ec61752f9e848a1d8cc7b405aef0356
./redis-trib.rb del-node 10.21.14.251:7001 bb1572074d41254e5b4d5aae5c52e54f5129d6d5
./redis-trib.rb del-node 10.21.14.251:7002 0c9b383f65ae4fefc5e02617fb76a845d7510a53
10. 干掉10.21.14.251:7002成功,
[redis@ip-10-21-14-251 redis]$ ./redis-trib.rb del-node 10.21.14.251:7002 0c9b383f65ae4fefc5e02617fb76a845d7510a53
>>> Removing node 0c9b383f65ae4fefc5e02617fb76a845d7510a53 from cluster 10.21.14.251:7002
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
[envuser@ip-10-21-14-251 redis]$ ./redis-trib.rb check 10.21.10.120:7000
>>> Performing Cluster Check (using node 10.21.10.120:7000)
M: 4422ab38377fa8828e0f7884570b3b482a66496b 10.21.10.120:7000
slots:3399-4999,5026-7332 (3908 slots) master
0 additional replica(s)
M: 5b38e63a1091baa3a871a52275489a2aa1d28bfb 10.21.10.120:7002
slots:894-3398,7333-15332,15949-16383 (10940 slots) master
0 additional replica(s)
M: bb1572074d41254e5b4d5aae5c52e54f5129d6d5 10.21.14.251:7001
slots: (0 slots) master
0 additional replica(s)
M: 396a7fbd2ec61752f9e848a1d8cc7b405aef0356 10.21.14.251:7000
slots: (0 slots) master
0 additional replica(s)
M: 9f215e7e4b511f3d2bbf5d734731899b71a62a3b 10.21.10.120:7001
slots:0-893,5000-5025,15333-15948 (1536 slots) master
0 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
状态检查
[redis@ip-10-21-14-251 redis]$ ./redis-cli -p 7000 cluster nodes
bb1572074d41254e5b4d5aae5c52e54f5129d6d5 10.21.14.251:7001 master - 0 1509611900094 6 connected
9f215e7e4b511f3d2bbf5d734731899b71a62a3b 10.21.10.120:7001 master - 0 1509611902100 14 connected 0-893 5000-5025 15333-15948
5b38e63a1091baa3a871a52275489a2aa1d28bfb 10.21.10.120:7002 master - 0 1509611901098 13 connected 894-3398 7333-15332 15949-16383
396a7fbd2ec61752f9e848a1d8cc7b405aef0356 10.21.14.251:7000 myself,master - 0 0 1 connected
4422ab38377fa8828e0f7884570b3b482a66496b 10.21.10.120:7000 master - 0 1509611899093 12 connected 3399-4999 5026-7332
根据上面步骤,删除剩余节点即可。
经过测试,应用在迁移过程中,没有受到任何影响。但是应用连接池的IP需要找机会增加10.21.10.120。
Redis Cluster在线迁移的更多相关文章
- 安全稳定实现redis cluster自动化迁移
背景 目前redis集群最火的是codis和redis cluster(官方),但官方自带工具并没有支持密码操作.那么需要密码认证使用redis cluster集群的同学要仔细看了哦. 相信大家很多人 ...
- redis cluster 添加/删除节点操作
RedisCluster 添加/删除节点 添加节点新配置两个测试节点8008和9009 [root@--- ~]# /usr/local/redis-/bin/redis-server /u02/re ...
- Redis Cluster高可用集群在线迁移操作记录【转】
之前介绍了redis cluster的结构及高可用集群部署过程,今天这里简单说下redis集群的迁移.由于之前的redis cluster集群环境部署的服务器性能有限,需要迁移到高配置的服务器上.考虑 ...
- Redis Cluster 4.0高可用集群安装、在线迁移操作记录
之前介绍了redis cluster的结构及高可用集群部署过程,今天这里简单说下redis集群的迁移.由于之前的redis cluster集群环境部署的服务器性能有限,需要迁移到高配置的服务器上.考虑 ...
- Redis Cluster高可用集群在线迁移操作记录
之前介绍了redis cluster的结构及高可用集群部署过程,今天这里简单说下redis集群的迁移.由于之前的redis cluster集群环境部署的服务器性能有限,需要迁移到高配置的服务器上.考虑 ...
- redis集群在线迁移
地址规划 主机名 ip地 端口 redis01 10.0.0.10 6379.6380 redis02 10.0.0.60 6379.6380 redis03 10.0.0.61 6379.6380 ...
- redis集群在线迁移第一篇(数据在线迁移至新集群)实战一
迁移背景:1.原来redis集群在A机房,需要把其迁移到新机房B上来.2.保证现有环境稳定.3.采用在线迁移方式,因为原有redis集群内有大量数据.4.如果是一个全新的redis集群搭建会简单很多. ...
- redis cluster 集群畅谈(三) 之 水平扩容、slave自动化迁移
上一篇http://www.cnblogs.com/qinyujie/p/9029522.html, 主要讲解 实验多master写入.读写分离.实验自动故障切换(高可用性),那么本篇我们就来聊了聊r ...
- redis cluster异地数据迁移,扩容,缩容
由于项目的服务器分布在重庆,上海,台北,休斯顿,所以需要做异地容灾需求.当前的mysql,redis cluster,elastic search都在重庆的如果重庆停电了,整个应用都不能用了. 现在考 ...
随机推荐
- 函数的嵌套+nonlocal和global关键字(重点)
1.在函数中声明函数 在内部函数中使用变量的时候, 查找顺序: 先找自己 -> 上一层 -> 上一层..全局 -> 内置 # 函数的互相调用 # def func1(): # pri ...
- cat & 文件结束符
语法: 连接显示 选项: -n,显示行号. -v,显示不可见打印符. -E,显示“行结束符”($). 显示行号 $ cat -n /etc/fstab /dev/VolGroup00/LogVol00 ...
- EasyuiDatagird绑定分页.NetMVC
引入EasyUi所有需要的脚本,样式 <link href="/easyui/themes/default/easyui.css" rel="stylesheet& ...
- JAVA 操作mysql 存储 调用
HashMap map = new HashMap(); map.put("a", 9); map.put("b", ""); List&l ...
- 【HQL】窗口函数
LAG LAG(col,n,DEFAULT) :与lead相反,用于统计窗口内往上第n行值.第一个参数为列名,第二个参数为往上第n行(可选,默认为1),第三个参数为默认值(当往上第n行为NULL时候, ...
- java 基础之 list
ArrayList 基于 array, 顾名思义. ArrayList是用数组实现的,这个数组的内存是连续的,不存在你说的相邻元素之间还隔着其他内存什么的 索引ArrayList时,速度比原生数组慢是 ...
- Flex4学习笔记2--代码保存在单独的文件中
1 <!--调用外部as文件--> <fx:Script> <![CDATA[ import mx.controls.Alert; import a.Test3; ]]& ...
- java接口的学习笔记
1接口 接口是一个特殊的类,在JAVA中,接口是由抽象方法和全局敞亮组成. 在JAVA忠使用INTERFACE定义接口. public class InterfaceDemo { public sta ...
- 错误:SyntaxError: Missing parentheses in call to 'print'
1.Python3编译器使用print函数需加括弧 print(XXX) 而Python 2可以print XXX 2.Python3表示不等只能用"!=" 3.在python3中 ...
- springMVC数据模型model,modelmap,map,@ModelAttribute的相互关系
结论: a.注解方法中形参为model,modelmap,map一个或几个时,他们指向的引用对象相同即他们的值相同. b.当使用@ModelAttribute注解请求参数时,springmvc自动将该 ...