详解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)
晴川运维晴川运维
上一篇 3天前
下一篇 3天前

相关推荐

  • 快速上手Zabbix使用方法

    Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已…

    Linux系统 3天前
  • 详解服务器负载

    平常的工作中,在衡量服务器的性能时,经常会涉及到几个指标,load、cpu、mem、qps、rt等。每个指标都有其独特的意义,很多时候在线上出现问题时,往往会伴随着某些指标的异常。…

    Linux系统 2025年6月8日
  • Linux lsblk命令实例

    lsblk命令用来查看block设备的信息.主要应用场景: 获取wwnid,获取块设备列表,获取块设备类型(ssd,hdd),获取块设备的size等信息。 系统环境 Centos7…

    Linux系统 2025年6月11日
  • 在 Kubernetes 上部署一个深度学习模型

    了解如何使用 Kubermatic Kubernetes 平台来部署、扩展与管理图像识别预测的深度学习模型。 随着企业增加了对人工智能(AI)、机器学习(ML)与深度学习(DL)的…

    Linux系统 2025年6月8日
  • Shell脚本习题:MySQL分库分表备份

    脚本详细内容 [root@db02 scripts]# cat /server/scripts/Store_backup.sh  &nbsp…

    Linux系统 2025年6月8日
  • lnav:Linux 下一个基于控制台的高级日志文件查看器

    服务器日志是一个由服务器创建并经常更新、用于抓取特定服务和应用的所有活动信息的日志文件。当你的应用或者服务出现问题时这个文件就会非常有用。从日志文件中你可以获取所有关于该问题的信息…

    Linux系统 2025年6月8日
  • Linux中进程通信方法

    每个进程各自有不同的用户地址空间,任何一个进程的全局变量在另一个进程中都看不到,所以进程之间要交换数据必须通过内核,在内核中开辟一块缓冲区,进程1把数据从用户空间拷到内核缓冲区,进…

    Linux系统 2025年6月11日
  • Ubuntu下查看路由表具体方法

    路由表的主要作用是供路由器查找目标网络,进而确定转发接口及下一跳路由,完成数据包的转发功能,在本篇文章中将为大家讲解一下如何在Ubuntu中查看网络路由表的具体方法。 什么是Lin…

    Linux系统 2025年6月4日
  • DNS在什么场景下选择TCP与UDP协议

    DNS同时占用UDP和TCP端口53是公认的,这种单个应用协议同时使用两种传输协议的情况在TCP/IP栈也算是个另类。但很少有人知道DNS分别在什么情况下使用这两种协议。 TCP与…

    Linux系统 2025年6月8日
  • Linux下查看最常使用命令

    Linux中如何查看自己常用的命令?在Linux系统中每天使用各种执行进行操作,但是大家知道自己使用最大的命令是什么吗?本篇文章重点为大家分享一下Linux下查看最常使用命令具体方…

    Linux系统 2025年6月12日

发表回复

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