详解Redis集群快捷迁移工具:Redis-migrate-tool

Redis-Migrate-Tool(都简称RMT),是唯品会开源的redis数据迁移工具,主要用于异构redis集群间的数据在线迁移,即数据迁移过程中源集群仍可以正常接受业务读写请求,无业务中断服务时间。

特点

快速

多线程

基于redis复制

实时迁移

迁移过程中,源集群不影响对外提供服务

异构迁移

支持Twemproxy集群,redis cluster集群,rdb文件 和 aof文件

过滤功能

当目标集群是Twemproxy,数据会跳过Twemproxy直接导入到后端的redis

迁移状态显示

完善的数据抽样校验

迁移工具的来源可以是:单独的redis实例,twemproxy集群,redis cluster,rdb文件,aof文件。

迁移工具的目标可以是:单独的redis实例,twemproxy集群,redis cluster,rdb文件。

版本说明

https://github.com/vipshop/redis-migrate-tool #仅支持redis3及以下版本

https://github.com/tanruixing88/redis-migrate-tool #基于上述版本修改,支持redis4及以上版本

依赖

yum -y install automake libtool autoconf bzip2

安装

git clone https://github.com/tanruixing88/redis-migrate-tool.git
redis-migrate-tool
autoreconf -fvi
./configure
make
cp src/redis-migrate-tool /usr/local/bin/redis-migrate-tool

配置文件rmt.conf

配置文件示例:从redis cluster集群迁移数据到twemproxy集群

[source]
type: redis cluster
servers:
- 127.0.0.1:6379
- 127.0.0.1:6380
- 127.0.0.1:6381
- 127.0.0.1:6382
[target]
type: twemproxy
hash: fnv1a_64
hash_tag: "{}"
distribution: ketama
servers:
- 127.0.0.1:6380:1 server1
- 127.0.0.1:6381:1 server2
- 127.0.0.1:6382:1 server3
- 127.0.0.1:6383:1 server4
[common]
listen: 0.0.0.0:8888
threads: 2
step: 1
mbuf_size: 1024
source_safe: true

配置文件示例:从redis cluster集群迁移数据到另外一个cluster集群

[source]
type: redis cluster
servers:
- 127.0.0.1:8379
[target]
type: redis cluster
servers:
- 127.0.0.1:7379
[common]
listen: 0.0.0.0:8888

配置文件示例:从rdb文件恢复数据到redis cluster集群

[source]
type: rdb file
servers:
- /data/redis/dump1.rdb
- /data/redis/dump2.rdb
- /data/redis/dump3.rdb
[target]
type: redis cluster
servers:
- 127.0.0.1:7379
[common]
listen: 0.0.0.0:8888

运行

/usr/local/bin/redis-migrate-tool -c rmt.conf -o log -d

状态

通过redis-cli连接redis-migrate-tool监控的端口,运行info命令

redis-cli -h 127.0.0.1 -p 8888
127.0.0.1:8888> info
# Server
version:0.1.0
os:Linux 2.6.32-573.12.1.el6.x86_64 x86_64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:9199
tcp_port:8888
uptime_in_seconds:1662
uptime_in_days:0
config_file:/ect/rmt.conf
# Clients
connected_clients:1
max_clients_limit:100
total_connections_received:3
# Memory
mem_allocator:jemalloc-4.0.4
# Group
source_nodes_count:32
target_nodes_count:48
# Stats
all_rdb_received:1
all_rdb_parsed:1
all_aof_loaded:0
rdb_received_count:32
rdb_parsed_count:32
aof_loaded_count:0
total_msgs_recv:7753587
total_msgs_sent:7753587
total_net_input_bytes:234636318
total_net_output_bytes:255384129
total_net_input_bytes_human:223.77M
total_net_output_bytes_human:243.55M
total_mbufs_inqueue:0
total_msgs_outqueue:0
127.0.0.1:8888>

数据校验

/usr/local/bin/redis-migrate-tool -c rmt.conf -o log -C redis_check
Check job is running...
Checked keys: 1000
Inconsistent value keys: 0
Inconsistent expire keys : 0
Other check error keys: 0
Checked OK keys: 1000
All keys checked OK!
Check job finished, used 1.041s

原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/9575.html

(0)
晴川运维晴川运维
上一篇 2025年6月18日
下一篇 2025年6月18日

相关推荐

  • Linux终端中使用Nmcli命令连接WiFi具体方法

    nmcli命令是redhat7或者centos7之后的命令,该命令可以完成网卡上所有的配置工作,并且可以写入配置文件,永久生效,本篇文章重点为大家讲解一下在Linux终端中使用Nm…

    Linux系统 2025年6月13日
  • 最受欢迎的10款Python开源框架总结

    本篇文章为大家讲解一下10个在GitHub等开源网站中最欢迎的Python开源框架,为大家做详细介绍和优劣势总结。这些框架包括Web开发,高性能网络通信,测试,爬虫等。 1.Dja…

    Linux系统 2025年6月29日
  • 讲解一下C 语言布尔类型

    C语言就没有真正的布尔类型,布尔类型实际上是用数值型(int,float,char等)表示的,不能自动打印为true或者false,只能自己写代码实现。 C 语言标准(C89) 没…

    Linux系统 2025年6月8日
  • Linux中历史命令的具体使用方法

    Linux系统当你在shell(控制台)中输入并执行命令时,shell会自动把你的命令记录到历史列表中,一般保存在用户目录下的.bash_history文件中。默认保存1000条,…

    Linux系统 2025年7月6日
  • ldconfig命令使用方法

    ldconfig是一个动态链接库管理命令,其目的为了让动态链接库为系统所共享,本篇文章重点为大家讲解一下ldconfig命令使用方法,有需要的小伙伴可以参考一下。 ldconfig…

    Linux系统 2025年6月19日
  • Linux下Bpftrace具体使用方法

    Bpftrace是Linux的新开源跟踪程序,用于分析生产性能问题和故障排除软件。 它的用户和贡献者包括Netflix,Facebook,Red Hat,Shopify等,它是由A…

    Linux系统 2025年6月22日
  • Oracle数据库基本使用方法

    Oracle数据库是目前世界上使用最为广泛的数据库管理系统,作为一个通用的数据库系统,它具有完整的数据管理功能;作为一个关系数据库,它是一个完备关系的产品;作为分布式数据库它实现了…

    Linux系统 2025年6月23日
  • Linux常用命令mmount命令具体使用方法

    Linux mmount命令用于挂入MS-DOS文件系统。 mmount为mtools工具指令,可根据[mount参数]中的设置,将磁盘内容挂入到Linux目录中。 语法 mmou…

    Linux系统 2025年6月8日
  • Linux中Postfix反病毒和垃圾邮件工具(十)

    amavisd-new amavisd-new呼叫器是一个连接MTA和内容检测工具(诸如病毒扫描工具和SpamAssassin)的高性能接口程序,使用perl语言写成。它一般通过S…

    Linux系统 2025年6月28日
  • Dockerfile中COPY 和 ADD命令

    Dockerfile 中提供了两个非常相似的命令 COPY 和 ADD,本篇文章为大家讲解两个命令的基本功能,以及其异同点,然后总结其各自适合的应用场景。 Build 上下文的概念…

    Linux系统 2025年7月2日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注