注意:目前不支持4.0.X及以上的redis使用

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文件。

#安装依赖:

yum install autoconf automake libtool bzip2

#linux机器上下载包

git clone https://github.com/vipshop/redis-migrate-tool

软件编译安装:

$ cd redis-migrate-tool

$ autoreconf -fvi

$ ./configure

$ make

$ src/redis-migrate-tool -h

软件运行:

src/redis-migrate-tool -c rmt.conf -o log -d

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

[source]type: redis clusterservers:- 127.0.0.1:6379

[target]type: twemproxyhash: fnv1a_64hash_tag: "{}"distribution: ketamaservers:- 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:34345threads: 8step: 1mbuf_size: 512source_safe: true

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

[source]type: redis clusterservers:- 127.0.0.1:8379

[target]type: redis clusterservers:- 127.0.0.1:7379

[common]listen: 0.0.0.0:8888

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

type: rdb fileservers:

- /data/redis/dump1.rdb

- /data/redis/dump2.rdb

- /data/redis/dump3.rdb

[target]type: redis clusterservers:

- 127.0.0.1:7379

[common]listen: 0.0.0.0:8888

配置文件示例:从单机迁移数据到另外一个单机

[source]
type: single
servers : 
-192.168.0.2:6379
redis_auth:redis

[target]
type: single
servers:
-192.168.0.5:6379

[common]
listen: 0.0.0.0:9999

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

$redis-cli -h 127.0.0.1 -p 8888127.0.0.1:8888> info# Serverversion:0.1.0os:Linux 2.6.32-573.12.1.el6.x86_64 x86_64multiplexing_api:epollgcc_version:4.4.7process_id:9199tcp_port:8888uptime_in_seconds:1662uptime_in_days:0config_file:/ect/rmt.conf

# Clientsconnected_clients:1max_clients_limit:100total_connections_received:3

# Memorymem_allocator:jemalloc-4.0.4

# Groupsource_nodes_count:32target_nodes_count:48

# Statsall_rdb_received:1all_rdb_parsed:1rdb_received_count:32rdb_parsed_count:32total_msgs_recv:7753587total_msgs_sent:7753587total_net_input_bytes:234636318total_net_output_bytes:255384129total_net_input_bytes_human:223.77Mtotal_net_output_bytes_human:243.55Mtotal_mbufs_inqueue:0total_msgs_outqueue:0127.0.0.1:8888>

查看log:

[root@redis04 redis-migrate-tool-master]# tail -f log
[2018-09-11 10:20:30.828] rmt_core.c:2551 migrate job is running...
[2018-09-11 10:20:30.828] rmt_redis.c:1706 Start connecting to MASTER[192.168.0.2:6379].
[2018-09-11 10:20:30.828] rmt_redis.c:1740 Master[192.168.0.2:6379] replied to PING, replication can continue...
[2018-09-11 10:20:30.829] rmt_redis.c:1051 Partial resynchronization for MASTER[192.168.0.2:6379] not possible (no cached master).
[2018-09-11 10:20:30.829] rmt_redis.c:1110 Full resync from MASTER[192.168.0.2:6379]: 05f9812b79e1e3e1ca95487d7acd360df644ad0a:18683803
[2018-09-11 10:20:31.120] rmt_redis.c:1517 MASTER <-> SLAVE sync: receiving 7844908 bytes from master[192.168.0.2:6379]
[2018-09-11 10:20:31.131] rmt_redis.c:1623 MASTER <-> SLAVE sync: RDB data for node[192.168.0.2:6379] is received, used: 0 s
[2018-09-11 10:20:31.131] rmt_redis.c:1643 rdb file node192.168.0.2:6379-1536632430829999-11046.rdb write complete
[2018-09-11 10:20:31.256] rmt_redis.c:6601 Rdb file for node[192.168.0.2:6379] parsed finished, use: 0 s.
[2018-09-11 10:20:31.258] rmt_redis.c:6709 All nodes' rdb file parsed finished for this write thread(0).

数据校验:

[root@redis04 redis-migrate-tool-master]# src/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 0.007s

参考来源:https://www.cnblogs.com/luckcs/articles/6477261.html

Redis-Migrate-Tool 使用详解的更多相关文章

  1. redis.conf 具体配置详解

    redis.conf 具体配置详解 # redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位, # 通常的格式就是 1k 5gb 4m 等酱紫: # # 1k => ...

  2. redis.windows.conf配置详解

    redis.windows.conf配置详解 转自:https://www.cnblogs.com/kreo/p/4423362.html # redis 配置文件示例 # 当你需要为某个配置项指定内 ...

  3. redis 五种数据结构详解(string,list,set,zset,hash)

    redis 五种数据结构详解(string,list,set,zset,hash) Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存 ...

  4. NoSQL之Redis高级实用命令详解--安全和主从复制

    Android IOS JavaScript HTML5 CSS jQuery Python PHP NodeJS Java Spring MySQL MongoDB Redis NOSQL Vim ...

  5. Redis的事务功能详解

    Redis的事务功能详解 MULTI.EXEC.DISCARD和WATCH命令是Redis事务功能的基础.Redis事务允许在一次单独的步骤中执行一组命令,并且可以保证如下两个重要事项: >Re ...

  6. redis 五种数据结构详解(string,list,set,zset,hash),各种问题综合

    redis 五种数据结构详解(string,list,set,zset,hash) https://www.cnblogs.com/sdgf/p/6244937.html redis 与 spring ...

  7. 【Redis】redis 五种数据结构详解(string,list,set,zset,hash)

    redis 五种数据结构详解(string,list,set,zset,hash) Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存 ...

  8. 反射实现Model修改前后的内容对比 【API调用】腾讯云短信 Windows操作系统下Redis服务安装图文详解 Redis入门学习

    反射实现Model修改前后的内容对比   在开发过程中,我们会遇到这样一个问题,编辑了一个对象之后,我们想要把这个对象修改了哪些内容保存下来,以便将来查看和追责. 首先我们要创建一个User类 1 p ...

  9. redis.conf配置信息详解

    redis.conf配置信息详解 配置文件 # Redis 配置文件 # 当配置中需要配置内存大小时,可以使用 1k, 5GB, 4M 等类似的格式,其转换方式如下(不区分大小写) # # 1k =& ...

  10. Redis进阶实践之二十 Redis的配置文件使用详解

    一.引言 写完上一篇有关redis使用lua脚本的文章,就有意结束Redis这个系列的文章了,当然了,这里的结束只是我这个系列的结束,但是要学的东西还有很多.但是,好多天过去了,总是感觉好像还缺点什么 ...

随机推荐

  1. 我的vim(持续更新)

    保存并退出:wq 退出但不保存修改:q! 不退出vi使用shell(bash)命令:!bash (如果想回到vi,bash下输入exit回车) 设置行号 :set nu 取消行号:set nonu 设 ...

  2. day3 python学习

    ---恢复内容开始--- 运算 在Python中有很多种运算方法,我们在这里只是先说比较运算,逻辑运算,赋值运算,算数运算 在这里要记住 ==  判断两个值是否相等  是比较运算符 >= 是否大 ...

  3. hasura graphql-engine v1.0.0-alpha30 功能试用

    hasura graphql-engine v1.0.0-alpha30 有好多新的功能的添加 环境准备 docker-compose 文件 version: '3.6' services: post ...

  4. python super()函数

    super()函数是用来调用父类(超类)的一个方法 super()的语法: python 2 的用法: super(Class, self).xxx  # class是子类的名称 class A(ob ...

  5. linux之 修改磁盘调度算法

    IO调度器的总体目标是希望让磁头能够总是往一个方向移动,移动到底了再往反方向走,这恰恰就是现实生活中的电梯模型,所以IO调度器也被叫做电梯. (elevator)而相应的算法也就被叫做电梯算法.而Li ...

  6. 1、Zookeeper安装及问题与集群

    1.下载zookeeper.tat.gz压缩包 2.解压 tar –xvf file.tar //解压 tar包 tar -xzvf file.tar.gz //解压tar.gz tar -xjvf ...

  7. Springboot技术点汇总

    1. Springboot+MyBatis+druid 在启动类上面,添加注释@Configuration以及@ImportResource(location={"classpath:con ...

  8. Spark版本说明

    Source code: Spark 源码,需要编译才能使用,另外 Scala 2.11 需要使用源码编译才可使用   Pre-build with user-provided Hadoop: &qu ...

  9. win764位系统上让32位程序能申请到4GB内存方法

    win764位系统上让32位程序能申请到4GB内存方法. 2016年09月18日 18:36:26 阅读数:1550 最近测试一个32位程序总是在1.2G左右内存时崩溃,怀疑是内存申请失败,本身32位 ...

  10. Nuke中新建线程的方法

    最近维护合成部门的nuke工具包,发现不少工具的使用方法都很个人化,没有说明文档.这也导致artist在使用工具的时候比较感性,调整参数的时候缺少前后逻辑,长此以往,artist会产生这种意识:只要最 ...