redis-cluster数据迁移
环境说明:
数据源:192.168.1.220
redis类型:redis-cluster
目的地:192.168.1.247
edis类型:redis-cluster
安装redis-migrate-tool
1、软件下载
wget https://github.com/vipshop/redis-migrate-tool/archive/master.zip
2、安装依赖包
yum install -y autoconf automake libtool bzip2
3、编译安装redis-migrate-tool
unzip redis-migrate-tool-master.zip
cd redis-migrate-tool-master
autoreconf -fvi
./configure
make
迁移redis数据
1、编辑同步配置文件
vim rmt.conf
[source]
type: redis cluster
servers :
- 172.19.0.183:6379
[target]
type: single
servers:
- 49.4.129.78:36379
[common]
listen: 0.0.0.0:8008
配置文件说明:
source是数据源的配置
target是目的位置
type是数据类型:
redis-cluster集群的类型就是redis-cluster
redis单点的类型为single
同步迁移数据
./redis-migrate-tool-master/src/redis-migrate-tool -c rmt.conf -o log -d
查看同步结果:
[2018-07-27 14:43:37.767] rmt_redis.c:6601 Rdb file for node[172.19.0.183:6379] parsed finished, use: 0 s.
[2018-07-27 14:43:37.768] rmt_redis.c:1706 Start connecting to MASTER[172.19.0.184:6379].
[2018-07-27 14:43:37.769] rmt_redis.c:1740 Master[172.19.0.184:6379] replied to PING, replication can continue...
[2018-07-27 14:43:37.769] rmt_redis.c:1051 Partial resynchronization for MASTER[172.19.0.184:6379] not possible (no cached master).
[2018-07-27 14:43:37.770] rmt_redis.c:1110 Full resync from MASTER[172.19.0.184:6379]: a0bff73aba29b5a40a0c19a144dcc059e315fa85:130620269
[2018-07-27 14:43:37.868] rmt_redis.c:1517 MASTER <-> SLAVE sync: receiving 2676933 bytes from master[172.19.0.184:6379]
[2018-07-27 14:43:37.876] rmt_redis.c:1623 MASTER <-> SLAVE sync: RDB data for node[172.19.0.184:6379] is received, used: 0 s
[2018-07-27 14:43:37.876] rmt_redis.c:1643 rdb file node172.19.0.184:6379-1532673817770506-10061.rdb write complete
[2018-07-27 14:43:37.984] rmt_redis.c:6601 Rdb file for node[172.19.0.184:6379] parsed finished, use: 0 s.
[2018-07-27 14:43:37.985] rmt_redis.c:6709 All nodes' rdb file parsed finished for this write thread(0).
由日志可以看出,所有节点的rdb数据迁移完毕。
参数说明
Options:
-h, --help : this help
-V, --version : show version and exit
-d, --daemonize : run as a daemon
-I, --information : print some useful information
-n, --noreply : don't receive the target redis reply
-v, --verbosity=N : set logging level (default: 5, min: 0, max: 11)
-o, --output=S : set logging file (default: stderr)
-c, --conf-file=S : set configuration file (default: rmt.conf)
-p, --pid-file=S : set pid file (default: off)
-m, --mbuf-size=N : set mbuf size (default: 512)
-C, --command=S : set command to execute (default: redis_migrate)
-r, --source-role=S : set the source role (default: single, you can input: single, twemproxy or redis_cluster)
-R, --target-role=S : set the target role (default: single, you can input: single, twemproxy or redis_cluster)
-T, --thread=N : set how many threads to run the job(default: 2)
-b, --buffer=S : set buffer size to run the job (default: 1048576 byte, unit:G/M/K)
-f, --from=S : set source redis address (default: 127.0.0.1:6379)
-t, --to=S : set target redis group address (default: 127.0.0.1:6380)
-s, --step=N : set step (default: 1)