redis-shake安装部署(4.0.2)

环境:
Os:Centos 7
redis-shake:4.0.2

说明:
redis源端和目的端都是单节点


1.项目地址
https://github.com/tair-opensource/RedisShake/tags

2.下载介质
我这里下载的版本是4.0.2,文件如下:
redis-shake-linux-amd64.tar.gz

 

3.安装
[root@localhost soft]# mkdir -p /opt/redis-shake
[root@localhost soft]# mv redis-shake-linux-amd64.tar.gz /opt/redis-shake/
[root@localhost soft]# cd /opt/redis-shake
[root@localhost redis-shake]# tar -xvf redis-shake-linux-amd64.tar.gz

 

 

4.修改配置文件(只修改红色部分)

[root@localhost redis-shake]# more shake.toml
function = ""


[sync_reader]
cluster = false
address = "192.168.1.108:7051"
username = ""              # keep empty if not using ACL
password = "redis123"              # keep empty if no authentication is required
tls = false

# [scan_reader]
# cluster = false
# address = "127.0.0.1:6379"
# username = ""              # keep empty if not using ACL
# password = ""              # keep empty if no authentication is required
# tls = false

# [rdb_reader]
# filepath = "/tmp/dump.rdb"

[redis_writer]
cluster = false
address = "192.168.1.109:7051"
username = ""              # keep empty if not using ACL
password = "redis123"              # keep empty if no authentication is required
tls = false

 

5.启动

[root@localhost redis-shake]# ./redis-shake /opt/redis-shake/shake.toml
2023-11-07 00:59:09 INF load config from file: /opt/redis-shake/shake.toml
2023-11-07 00:59:09 INF log_level: [info], log_file: [/opt/redis-shake/data/shake.log]
2023-11-07 00:59:09 INF changed work dir to [/opt/redis-shake/data]
2023-11-07 00:59:09 INF GOMAXPROCS defaults to the value of runtime.NumCPU [1]
2023-11-07 00:59:09 INF not set pprof port
2023-11-07 00:59:09 INF no function script
2023-11-07 00:59:09 INF create SyncStandaloneReader: 192.168.1.108:7051
2023-11-07 00:59:09 INF create RedisStandaloneWriter: 192.168.1.109:7051
2023-11-07 00:59:09 INF not set status port
2023-11-07 00:59:09 INF start syncing...
2023-11-07 00:59:14 INF read_count=[11], read_ops=[0.00], write_count=[11], write_ops=[0.00], syncing aof, diff=[0]
2023-11-07 00:59:19 INF read_count=[11], read_ops=[0.00], write_count=[11], write_ops=[0.00], syncing aof, diff=[0]
2023-11-07 00:59:24 INF read_count=[11], read_ops=[0.00], write_count=[11], write_ops=[0.00], syncing aof, diff=[0]
2023-11-07 00:59:29 INF read_count=[11], read_ops=[0.00], write_count=[11], write_ops=[0.00], syncing aof, diff=[0]
2023-11-07 00:59:34 INF read_count=[11], read_ops=[0.00], write_count=[11], write_ops=[0.00], syncing aof, diff=[0]
2023-11-07 00:59:39 INF read_count=[11], read_ops=[0.00], write_count=[11], write_ops=[0.00], syncing aof, diff=[0]

 

6.登录到目的库进行验证
/usr/local/services/redis/bin/redis-cli -h 192.168.1.109 -p 7051 -a redis123
192.168.1.109:7051> keys

 

 

####################可以读取源库的rdb文件#########################

1.源库生成rdb文件
192.168.1.108:7051> bgsave
Background saving started

 

2.将rdb文件拷贝到目的库
[root@localhost data]# scp dump-7051.rdb root@192.168.1.109:/tmp/

 

3.目的库导入
先清空当前的所有的key
192.168.1.109:7051> flushall
OK

192.168.1.109:7051> keys *
(empty list or set)

 

4.修改redis-shake配置文件

##[sync_reader]
##cluster = false
##address = "192.168.1.108:7051"
##username = ""              # keep empty if not using ACL
##password = "redis123"              # keep empty if no authentication is required
##tls = false

# [scan_reader]
# cluster = false
# address = "127.0.0.1:6379"
# username = ""              # keep empty if not using ACL
# password = ""              # keep empty if no authentication is required
# tls = false

[rdb_reader]
filepath = "/tmp/dump-7051.rdb"

[redis_writer]
cluster = false
address = "192.168.1.109:7051"
username = ""              # keep empty if not using ACL
password = "redis123"              # keep empty if no authentication is required
tls = false

 

5.执行同步

[root@localhost redis-shake]# ./redis-shake /opt/redis-shake/shake.toml
2023-11-07 01:20:26 INF load config from file: /opt/redis-shake/shake.toml
2023-11-07 01:20:26 INF log_level: [info], log_file: [/opt/redis-shake/data/shake.log]
2023-11-07 01:20:26 INF changed work dir to [/opt/redis-shake/data]
2023-11-07 01:20:26 INF GOMAXPROCS defaults to the value of runtime.NumCPU [1]
2023-11-07 01:20:26 INF not set pprof port
2023-11-07 01:20:26 INF no function script
2023-11-07 01:20:26 INF create RdbReader: /tmp/dump-7051.rdb
2023-11-07 01:20:26 INF create RedisStandaloneWriter: 192.168.1.109:7051
2023-11-07 01:20:26 INF not set status port
2023-11-07 01:20:26 INF start syncing...
2023-11-07 01:20:26 INF [rdb_reader] start read
2023-11-07 01:20:26 INF [rdb_reader] rdb file parse done
2023-11-07 01:20:26 INF all done

 

#####################各环境同步配置文件说明########################

1.单节点到集群的配置

function = ""


[sync_reader]
cluster = false
address = "192.168.1.108:7051"
username = ""              # keep empty if not using ACL
password = "redis123"              # keep empty if no authentication is required
tls = false

# [scan_reader]
# cluster = false
# address = "127.0.0.1:6379"
# username = ""              # keep empty if not using ACL
# password = ""              # keep empty if no authentication is required
# tls = false

#[rdb_reader]
#filepath = "/tmp/dump-7051.rdb"

[redis_writer]
cluster = true
address = "192.168.1.109:8001"
username = ""              # keep empty if not using ACL
password = "redis123"              # keep empty if no authentication is required
tls = false

 

集群环境的address可以写主节点的地址,也可以写从节点的地址,程序自动会判断主节点并从主节点写入.

 

2.集群同步到单节点

function = ""


[sync_reader]
cluster = true
address = "192.168.1.109:7001"
username = ""              # keep empty if not using ACL
password = "redis123"              # keep empty if no authentication is required
tls = false

# [scan_reader]
# cluster = false
# address = "127.0.0.1:6379"
# username = ""              # keep empty if not using ACL
# password = ""              # keep empty if no authentication is required
# tls = false

#[rdb_reader]
#filepath = "/tmp/dump-7051.rdb"

[redis_writer]
cluster = false
address = "192.168.1.108:7051"
username = ""              # keep empty if not using ACL
password = "redis123"              # keep empty if no authentication is required
tls = false

 

posted @ 2023-11-07 14:04  slnngk  阅读(965)  评论(0编辑  收藏  举报