Redis 集群迁移工具,基于redis复制,快速,稳定。
github链接:https://github.com/vipshop/redis-migrate-tool
特点:
迁移工具的来源可以是:单独的redis实例,twemproxy集群,redis cluster,rdb文件,aof文件。
迁移工具的目标可以是:单独的redis实例,twemproxy集群,redis cluster,rdb文件。
wget https://github.com/vipshop/redis-migrate-tool/archive/master.zip -O redis-migrate-tool.zip
yum -y install autoconf automake libtool bzip2 zip unzip
unzip redis-migrate-tool-master.zip
cd redis-migrate-tool-master
autoreconf -fvi
./configure
make
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-09LDTFaI-1578299755570)(images/image-20200103100504752.png)]
cd /opt/server/redis-migrate-tool-master
vim rmt.conf
[source]
type: rdb file
servers:
- /opt/server/dump.rdb
[target]
type: redis cluster
servers:
- 127.0.0.1:6379
- 127.0.0.1:6380
- 127.0.0.1:6381
[common]
listen: 0.0.0.0:8888
./src/redis-migrate-tool -c rmt.conf -d
可能出现版本错误
ERROR: Can't handle RDB format version 839003080
原因:redis-migrate-tool迁移工具最高支持到rdb7版本,而你使用的redis生成rdb版本已经超过了7,例如,你是用的redis5.0
修改 rmt_redis.c 文件,将7改为8或更高的数
/* ========================== Redis RDB ============================ */
/* The current RDB version. When the format changes in a way that is no longer
* backward compatible this number gets incremented. */
#define REDIS_RDB_VERSION 7
重新运行
[root@redis redis-migrate-tool-master]# ./src/redis-migrate-tool -c rmt.conf -d
[2020-01-02 18:54:50.569] rmt_core.c:525 Nodes count of source group : 1
[2020-01-02 18:54:50.569] rmt_core.c:526 Total threads count : 2
[2020-01-02 18:54:50.569] rmt_core.c:527 Read threads count assigned: 1
[2020-01-02 18:54:50.569] rmt_core.c:528 Write threads count assigned: 1
[2020-01-02 18:54:50.570] rmt_core.c:2444 Total threads count in fact: 1
[2020-01-02 18:54:50.570] rmt_core.c:2445 Read threads count in fact: 0
[2020-01-02 18:54:50.570] rmt_core.c:2446 Write threads count in fact: 1
[2020-01-02 18:54:50.570] rmt_core.c:2488 write thread(0):
[2020-01-02 18:54:50.570] rmt_core.c:2494 /opt/server/dump.rdb
[2020-01-02 18:54:50.570] rmt_core.c:2551 migrate job is running...
[2020-01-02 18:54:51.228] rmt_redis.c:6601 Rdb file for node[/opt/server/dump.rdb] parsed finished, use: 0 s.