Skip to content

如何指定目标redis的库号? #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sxlstevengit opened this issue Apr 8, 2025 · 5 comments
Open

如何指定目标redis的库号? #946

sxlstevengit opened this issue Apr 8, 2025 · 5 comments
Assignees
Labels
type: feature request New feature or request

Comments

@sxlstevengit
Copy link

工作中遇到这样的场景:把源库中所有DB的数据, 全部同步到目标库DB 1中,需要怎么配置?
我查到redis-shake2.0.3具有这个功能,指定:target.db = 1即可。 但是最新版本没有这个配置选项,请问最新版如何实现?

@sxlstevengit sxlstevengit added the type: feature request New feature or request label Apr 8, 2025
@suxb201
Copy link
Member

suxb201 commented Apr 8, 2025

参考交换 DB 的脚本,写一个符合你需求的脚本:https://tair-opensource.github.io/RedisShake/zh/filter/function.html#%E4%BA%A4%E6%8D%A2-db

@sxlstevengit
Copy link
Author

Thank you

@ziyou987
Copy link

ziyou987 commented Apr 14, 2025

我试过交换DB的配置,还是不能指定目标redis的库号,请问有最佳实践吗 @suxb201 @sxlstevengit
配置文件:
function = """
shake.log(DB)
local db1 = 0
local db2 = 9

if DB == db1 then
DB = db2
end
shake.call(DB, ARGV)
"""

[scan_reader]
cluster = false # set to true if source is a redis cluster
address = "127.0.0.1:6379" # when cluster is true, set address to one of the cluster node
username = "" # keep empty if not using ACL
password = "redis01pass" # keep empty if no authentication is required
ksn = false # set to true to enabled Redis keyspace notifications (KSN) subscription
tls = false

[redis_writer]
cluster = false # set to true if target is a redis cluster
address = "127.0.0.1:6380" # when cluster is true, set address to one of the cluster node
username = "" # keep empty if not using ACL
password = "redis01pass" # keep empty if no authentication is required
tls = false

运行结果:

Image

@suxb201
Copy link
Member

suxb201 commented Apr 14, 2025

https://github.com/tair-opensource/RedisShake/blob/v4/shake.toml
function 在 filter 下面,你需要开头写 [filter]

@ziyou987
Copy link

https://github.com/tair-opensource/RedisShake/blob/v4/shake.toml 函数在filter下面,你需要写[filter]

可以了,你真棒

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants