redis-trib.rb reshard针对有键值的slot迁移失败 Wrong number of arguments for specified sub command

我不是女神ヾ 2021-10-15 07:01 401阅读 0赞

运行环境:

redis :4.0

redis-trib.rb redis集群管理脚本

ruby: 2.6.3

在执行reshard命令时发现迁移有键值的slot时就会报错Wrong number of arguments for specified sub command,谷歌找到的答案是redis-trib.rb脚本的兼容性问题,需要修改这个脚本migrate部分代码:

  1. \# Migrate all the keys from source to target using the MIGRATE command
  2. while true
  3. keys = source.r.cluster("getkeysinslot",slot,o\[:pipeline\])
  4. break if keys.length == 0
  5. begin
  6. source.r.**client.**call(\["migrate",target.info\[:host\],target.info\[:port\],"",0,@timeout,:keys,\*keys\])
  7. rescue => e
  8. if o\[:fix\] && e.to\_s =~ /BUSYKEY/
  9. xputs "\*\*\* Target key exists. Replacing it for FIX."
  10. source.r.**client.**call(\["migrate",target.info\[:host\],target.info\[:port\],"",0,@timeout,:replace,:keys,\*keys\])

将标红部分删除即可,即变成下面:

  1. \# Migrate all the keys from source to target using the MIGRATE command
  2. while true
  3. keys = source.r.cluster("getkeysinslot",slot,o\[:pipeline\])
  4. break if keys.length == 0
  5. begin
  6. source.r.call(\["migrate",target.info\[:host\],target.info\[:port\],"",0,@timeout,:keys,\*keys\])
  7. rescue => e
  8. if o\[:fix\] && e.to\_s =~ /BUSYKEY/
  9. xputs "\*\*\* Target key exists. Replacing it for FIX."
  10. source.r.call(\["migrate",target.info\[:host\],target.info\[:port\],"",0,@timeout,:replace,:keys,\*keys\])

参考文章:

https://github.com/antirez/redis/issues/2547

发表评论

表情:
评论列表 (有 0 条评论,401人围观)

还没有评论,来说两句吧...

相关阅读