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

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 "^#"

bash 复制代码
[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开始全量和增量同步数据

相关推荐
草莓熊Lotso1 天前
【Redis 初阶】Set 类型深度解析:去重集合的运算能力与实战场景
linux·网络·数据库·windows·redis·tcp/ip·缓存
IT大白鼠1 天前
Docker 实战 ELKF 日志监控:容器日志全栈收集分析方案
运维·docker·容器
报错小能手1 天前
Kubernetes入门实战课 3
云原生·容器·kubernetes
小张同学a.2 天前
Docker 容器实战 1—— docker 基础与镜像构建
linux·运维·docker·容器
NJCloud2 天前
Docker 容器技术入门:部署、核心概念与基础命令
运维·docker·容器
小白勇闯网安圈2 天前
String、Hash、List、Set 四大数据结构与通用命令
redis
2601_962072332 天前
docker自建rustdesk-server远程桌面
运维·docker·容器
2601_962071172 天前
八. Spring Boot2 整合连接 Redis(超详细剖析)
spring boot·redis·后端
报错小能手2 天前
Kubernetes入门实战课 1
云原生·容器·kubernetes
程序员夏洛2 天前
Redis 数据过期后的删除策略是什么?
数据库·redis·缓存