欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 旅游 > Redis数据同步

Redis数据同步

2024/10/24 13:31:36 来源:https://blog.csdn.net/Pluto_CSND/article/details/140323373  浏览:    关键词:Redis数据同步

文章简单介绍基于redis-shake的redis数据同步,该工具基于每个节点同步数据,即每个主节点需同步一次,才能完成整个redis集群的数据同步。

1、redis节点操作

### 查看redis版本
./bin/redis-server --version### 登录redis
./bin/redis-cli -c -h *.*.*.142 -p 17001 -a '******'### 查看数据量
> info keyspace### 批量删除keys
./bin/redis-cli  -c -h *.*.*.142 -p 17001 -a '******' keys  "*@_@*"  | xargs -r -t -n1 ./bin/redis-cli -c -h *.*.*.142 -p 17001 -a '******' del./bin/redis-cli  -c -h *.*.*.144 -p 17001 -a '******' keys  "auth-dw*"  | xargs -r -t -n1 ./bin/redis-cli -c -h *.*.*.144 -p 17001 -a '******' del### 删除所有keys
> flushall### 查看set类型变量的内容
smembers "auth-ds:446fc...@24cfd7b0..."

2、redis-shake 配置与启动

编辑配置文件 vim ./sync.toml
type = "sync"[source]
version = 7.0 # redis version, such as 2.8, 4.0, 5.0, 6.0, 6.2, 7.0, ...
address = "*.*.*.93:17001"
username = "" # keep empty if not using ACL
password = "******" # keep empty if no authentication is required
tls = false
elasticache_psync = "" # using when source is ElastiCache. ref: https://github.com/alibaba/RedisShake/issues/373[target]
type = "standalone" # "standalone" or "cluster"  
version = 7.0 # redis version, such as 2.8, 4.0, 5.0, 6.0, 6.2, 7.0, ...# When the target is a cluster, write the address of one of the nodes.# redis-shake will obtain other nodes through the `cluster nodes` command.address = "*.*.*.142:17001"
username = "" # keep empty if not using ACL
password = "******" # keep empty if no authentication is required
tls = false[advanced]
dir = "data"ncpu = 4 # runtime.GOMAXPROCS, 0 means use runtime.NumCPU() cpu corespprof_port = 0 # pprof port, 0 means disablemetrics_port = 0 # metric port, 0 means disablelog_file = "redis-shake.log"
log_level = "info" # debug, info or warn
log_interval = 5 # in secondsrdb_restore_command_behavior = "skip" # panic, rewrite or skippipeline_count_limit = 1024 # pipelinetarget_redis_client_max_querybuf_len = 1024_000_000target_redis_proto_max_bulk_len = 512_000_000
启动redis-shake同步数据
nohup ./redis-shake sync.toml 1>> redis-shake.log 2>> redis-shake.log &

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com