redis数据迁移工具redis-migrate-tool安装使用

Redis-Migrate-Tool 使用详解

Redis 集群迁移工具,基于redis复制,快速,稳定。
github链接:https://github.com/vipshop/redis-migrate-tool

特点:

  • 快速。
  • 多线程。
  • 基于redis复制。
  • 实时迁移。
  • 迁移过程中,源集群不影响对外提供服务。
  • 异构迁移。
  • 支持Twemproxy集群,redis cluster集群,rdb文件 和 aof文件。
  • 过滤功能。
  • 当目标集群是Twemproxy,数据会跳过Twemproxy直接导入到后端的redis。
  • 迁移状态显示。
  • 完善的数据抽样校验。

迁移工具的来源可以是:单独的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

修改redis-migrate-tool源码后重新编译

修改 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.
发布了30 篇原创文章 · 获赞 7 · 访问量 3898

猜你喜欢

转载自blog.csdn.net/huchao_lingo/article/details/103859967