1.簡介
Redis-shake是阿里開源的使用golang語言開發的Redis數據同步工具,支持redis standalone、sentinel、cluster。
github地址 https://github.com/alibaba/RedisShake
支持的遷移模式:
decode: 把Redis RDB文件解析成人類可讀的文件格式.
restore: 把Rdis RDB文件作為數據源,恢復到目標Redis實例中.
dump: 對源Redis實例中的數據dump到RDB文件中.
sync: 基於Redis sync/psync命令從源redis實例同步到目標Redis實例,該模式包含全量同步和增量同步兩個階段。(通過默認Redis Slave來實現).
rump: 基於Redis scan命令的方式從源Redis同步到目標Redis實例。只支持全量同步,這種方式通常適用於源redis不支持sync/psync命令的場景.
2.下載
wget https://github.com/alibaba/RedisShake/releases/download/release-v2.1.1-20210903/release-v2.1.1-20210903.tar.gz //下載
tar zxvf release-v2.1.1-20210903.tar.gz //解壓
解壓之后會看到以下文件,我們一般只會用到redis-shake.conf
3.配置文件修改:
單個節點到單個節點restore模式配置文件修改:
log.file =/opt/redis-shake/redis-shake.log //工具運行日志文件路徑
http_profile = -1 //查看 metric 端口, -1 表示不啟用. 如果是`restore`模式,只有設置為-1才會在完成RDB恢復后退出,否則會一直block。
source.address = 192.168.79.151:6379 //源端IP地址和端口
source.rdb.input = /mnt/data/redis/dump.rdb //源端RDB文件路徑
target.address = 192.168.79.146:6379 //目的端IP地址和端口
target.rdb.output = /mnt/data/redis/redisdump.rdb //目的端RDB文件的存放路徑
key_exists = rewrite //當源端和目的段有相同的key時,是否進行覆蓋,“rewrite”表示覆蓋目的段的key值
4.執行啟動命令:
./redis-shake.linux -type=restore -conf=redis-shake.conf //restore模式