博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Redis单实例数据迁移到集群
阅读量:5034 次
发布时间:2019-06-12

本文共 4026 字,大约阅读时间需要 13 分钟。

环境说明

单机redis

192.168.41.101:6379

redis集群

192.168.41.101:7000 master192.168.41.101:7001 master192.168.41.101:7002192.168.41.102:7000 master192.168.41.102:7001192.168.41.102:7002

迁移步骤

查看集群状态及节点槽分布

[root@blaze bin]# ./redis-cli -c -p 7000127.0.0.1:7000> cluster nodesab6d9f956de325cb4cf001abc31df365a5db5234 192.168.41.102:7001 slave 923c9ea13ec8fc19bed309dfbfad094320e1ca41 0 1560304528263 7 connected48629733acbb8a580a39403dfac92845d63c97b3 192.168.41.101:7001 master - 0 1560304529768 2 connected 5461-109212cec8ac00f760c45d86f7903cefad85ec36704e7 192.168.41.102:7002 slave 923c9ea13ec8fc19bed309dfbfad094320e1ca41 0 1560304531271 7 connected923c9ea13ec8fc19bed309dfbfad094320e1ca41 192.168.41.101:7000 myself,master - 0 0 7 connected 0-5460e65b319e83997ed6f5323a26aaccba3f35522cbd 192.168.41.101:7002 slave 923c9ea13ec8fc19bed309dfbfad094320e1ca41 0 1560304532274 7 connected5c0888d5bcceda2904311cbd5405596217c48105 192.168.41.102:7000 master - 0 1560304530268 4 connected 10922-16383
[root@blaze src]# ./redis-trib.rb check 192.168.41.101:7000>>> Performing Cluster Check (using node 192.168.41.101:7000)M: 923c9ea13ec8fc19bed309dfbfad094320e1ca41 192.168.41.101:7000   slots:0-5460 (5461 slots) master   3 additional replica(s)S: ab6d9f956de325cb4cf001abc31df365a5db5234 192.168.41.102:7001   slots: (0 slots) slave   replicates 923c9ea13ec8fc19bed309dfbfad094320e1ca41M: 48629733acbb8a580a39403dfac92845d63c97b3 192.168.41.101:7001   slots:5461-10921 (5461 slots) master   0 additional replica(s)S: 2cec8ac00f760c45d86f7903cefad85ec36704e7 192.168.41.102:7002   slots: (0 slots) slave   replicates 923c9ea13ec8fc19bed309dfbfad094320e1ca41S: e65b319e83997ed6f5323a26aaccba3f35522cbd 192.168.41.101:7002   slots: (0 slots) slave   replicates 923c9ea13ec8fc19bed309dfbfad094320e1ca41M: 5c0888d5bcceda2904311cbd5405596217c48105 192.168.41.102:7000   slots:10922-16383 (5462 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.

 

把101:7001和102:7000两个master的slots转移到101:7000上

./redis-trib.rb reshard --from 5c0888d5bcceda2904311cbd5405596217c48105 --to 923c9ea13ec8fc19bed309dfbfad094320e1ca41  --slots 5462 --yes 192.168.41.101:7000./redis-trib.rb reshard --from 48629733acbb8a580a39403dfac92845d63c97b3 --to 923c9ea13ec8fc19bed309dfbfad094320e1ca41  --slots 5461 --yes 192.168.41.101:7000

 

查看转以后槽点分配

>>> Performing Cluster Check (using node 192.168.41.101:7000)M: 923c9ea13ec8fc19bed309dfbfad094320e1ca41 192.168.41.101:7000   slots:0-16383 (16384 slots) master   3 additional replica(s)S: ab6d9f956de325cb4cf001abc31df365a5db5234 192.168.41.102:7001   slots: (0 slots) slave   replicates 923c9ea13ec8fc19bed309dfbfad094320e1ca41M: 48629733acbb8a580a39403dfac92845d63c97b3 192.168.41.101:7001   slots: (0 slots) master   0 additional replica(s)S: 2cec8ac00f760c45d86f7903cefad85ec36704e7 192.168.41.102:7002   slots: (0 slots) slave   replicates 923c9ea13ec8fc19bed309dfbfad094320e1ca41S: e65b319e83997ed6f5323a26aaccba3f35522cbd 192.168.41.101:7002   slots: (0 slots) slave   replicates 923c9ea13ec8fc19bed309dfbfad094320e1ca41M: 5c0888d5bcceda2904311cbd5405596217c48105 192.168.41.102:7000   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.

把192.168.41.101:6379的appendonly.aof 文件复制到101:7000的aof文件目录下

cp 6379目录/appendonly.aof   7000目录

重启101:7000节点加载aof文件

[root@blaze bin]# ./redis-cli -c -p 7000 shutdown[root@blaze bin]# ./redis-server ../redis.conf

查看数据是否正确

dbsize

 

将101:7000的槽 均匀分配给其他两个master节点

./redis-trib.rb reshard --from 923c9ea13ec8fc19bed309dfbfad094320e1ca41  --to 5c0888d5bcceda2904311cbd5405596217c48105  --slots 5462 --yes 192.168.41.101:7000./redis-trib.rb reshard --from 923c9ea13ec8fc19bed309dfbfad094320e1ca41  --to 48629733acbb8a580a39403dfac92845d63c97b3  --slots 5461 --yes 192.168.41.101:7000

再次查看集群状态和槽分配。

 

转载于:https://www.cnblogs.com/blazeZzz/p/11007977.html

你可能感兴趣的文章
CentOS6.7源码安装MySQL5.6
查看>>
android Bitmap总结
查看>>
触发器简介
查看>>
JAVA反射机制的学习
查看>>
mysql - rollup 使用
查看>>
Chrome系列 Failed to load resource: net::ERR_CACHE_MISS
查看>>
出现函数重载错误call of overloaded ‘printfSth(double)’ is ambiguous
查看>>
SDUT 1941-Friday the Thirteenth(水)
查看>>
java API连接虚拟机上的hbase
查看>>
c#扩展出MapReduce方法
查看>>
Cookie工具类 - CookieUtil.java
查看>>
[转载]linux下各文件夹的结构说明及用途介绍
查看>>
《敏捷开发绩效管理》扩展阅读(敏捷开发绩效管理,敏捷团队绩效管理)
查看>>
Jquery怎么获取select选中项 自定义属性的值
查看>>
CKEditor (Toolbar Definition)工具栏自定义配置
查看>>
在vscode成功配置Python环境
查看>>
mysql table 最新更新时间
查看>>
个人永久性免费-Excel催化剂功能第37波-把Sqlserver的强大分析函数拿到Excel中用...
查看>>
PHP中字符串比较的常用方法
查看>>
html5--6-2 CSS语法
查看>>