Kubernetes集群外连接redis集群和使用redis-shake工具迁移数据(一)
Kubernetes集群外连接redis集群和使用redis-shake工具迁移数据(二)

一、RedisShake

RedisShake 是一个 Redis 数据同步工具,主要用于实现两个 Redis 实例之间的数据同步。它支持多种同步模式,包括但不限于:

全量同步:将源 Redis 实例中的所有数据复制到目标实例中。
增量同步:在全量同步之后,继续监听源实例的数据变化,并实时同步到目标实例。
指定键同步:用户可以指定需要同步的键或键模式,这样只有符合模式的数据会被同步。
RedisShake 的设计目的是为了满足不同场景下的数据迁移、备份、复制等需求,它能够帮助用户减少数据同步过程中的复杂性和错误率。此外,RedisShake 支持跨网络环境的数据同步,比如从本地环境同步数据到云上环境,或者在不同的云服务提供商之间进行数据同步。

使用 RedisShake 进行数据同步时,通常需要注意配置文件的设置,确保源和目标 Redis 实例的连接信息正确无误,并根据实际需求选择合适的同步模式。此外,还需要考虑同步过程中可能遇到的数据冲突处理方式,以及如何保证数据的一致性等问题。
GitHub地址:https://github.com/tair-opensource/RedisShake
官方地址:https://tair-opensource.github.io/RedisShake/zh

二、Cluster模式迁移

编辑 shake.toml 文件
cat shake.toml | grep -v "^#"

[sync_reader]
cluster = true   #源是集群模式,需要开启         # set to true if source is a redis cluster
address = "源redis url:6379" # when cluster is true, set address to one of the cluster node
username = ""              # keep empty if not using ACL
password = "woshimima"              # keep empty if no authentication is required
tls = false                #
sync_rdb = true            # set to false if you don't want to sync rdb
sync_aof = true            # set to false if you don't want to sync aof
prefer_replica = false     # set to true if you want to sync from replica node
try_diskless = false       # set to true if you want to sync by socket and source repl-diskless-sync=yes




[redis_writer]
cluster = true    #源是集群模式,需要开启         # set to true if target is a redis cluster
sentinel = false           # set to true if target is a redis sentinel
master = ""                # set to master name if target is a redis sentinel
address = "192.168.1.10:30111" # when cluster is true, set address to one of the cluster node
username = ""              # keep empty if not using ACL
password = "woshimima"              # keep empty if no authentication is required
tls = false
off_reply = false          # turn off the server reply

[filter]
allow_key_prefix = []
allow_key_suffix = []

block_key_prefix = []
block_key_suffix = []

allow_db = []
block_db = []

allow_command = [] 
block_command = [] 

allow_command_group = [] 
block_command_group = [] 

function = ""

[advanced]
dir = "data"
ncpu = 0        # runtime.GOMAXPROCS, 0 means use runtime.NumCPU() cpu cores
pprof_port = 0  # pprof port, 0 means disable
status_port = 0 # status port, 0 means disable

log_file = "shake.log"
log_level = "info"     # debug, info or warn
log_interval = 5       # in seconds

rdb_restore_command_behavior = "panic" # panic, rewrite or skip

pipeline_count_limit = 1024

target_redis_client_max_querybuf_len = 1073741824  # 1GB in bytes

target_redis_proto_max_bulk_len = 512_000_000

aws_psync = "" # example: aws_psync = "10.0.0.1:6379@nmfu2sl5osync,10.0.0.1:6379@xhma21xfkssync"

empty_db_before_sync = false

[module]
target_mbbloom_version = 20603

我测试的时候,打了一个redis-shake 4.2.1版本的镜像swr.cn-north-4.myhuaweicloud.com/asdl-aps/softwares/redis-shake:20241119,进入到cd /RedisShake/bin/目录下,运行./redis-shake shake.toml开始全量和增量同步数据

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部