redisshake同步例子(过滤同步)
环境:
OS:Centos 7
RedisShake:v4.2.2
1.下载地址
https://github.com/tair-opensource/RedisShake/releases/download/v4.2.2/redis-shake-linux-amd64.tar.gz
2.解压安装
mkdir -p /opt/redis-shake ##安装包上传到该目录
tar -xvf redis-shake-linux-amd64.tar.gz
3.修改配置文件
vi /opt/redis-shake/shake.toml
4.执行迁移
/opt/redis-shake /opt/redis-shake/shake.toml
配置例子:
1.ecs自己单机redis迁移到阿里云云服务redis(集群模式)
[sync_reader]
cluster = false # set to true if source is a redis cluster
address = "172.1.40.200:6379" # when cluster is true, set address to one of the cluster node
username = "" # keep empty if not using ACL
password = "aaaaaaaaa" # keep empty if no authentication is required
[redis_writer]
cluster = false # 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 = "r-wzeeeeeeeeeeee:6379" # when cluster is true, set address to one of the clust
er node
username = "" # keep empty if not using ACL
password = "aaaaaaa" # keep empty if no authentication is required
[filter]
# Allow keys with specific prefixes or suffixes
# Examples:
# allow_key_prefix = ["user:", "product:"]
# allow_key_suffix = [":active", ":valid"]
# Leave empty to allow all keys
allow_key_prefix = ["hxl"]
allow_key_suffix = []
说明:
a.目标端阿里云的地址是代理模式的url,内部是集群,但是这里cluster设置成false
b.只同步hxl开头的key
c.需要将程序运行所在ECS的ip加入到阿里云redis云服务的白名单。
d.可以重复执行同步,存在的key会删除
e.过滤多个key,以分号分隔,如:allow_key_prefix = ["hxl","jjf"]
2.集群到集群(自建)
[sync_reader]
cluster = true # set to true if source is a redis cluster
address = "192.168.1.100:6379" # when cluster is true, set address to one of the cluster node
username = "" # keep empty if not using ACL
password = "2018" # keep empty if no authentication is required
[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.101:6479" # when cluster is true, set address to one of the cluster node
username = "" # keep empty if not using ACL
password = "2018" # keep empty if no authentication is required