前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >redis-trib.rb reshard针对有键值的slot迁移失败 Wrong number of arguments for specified sub command

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

作者头像
johnhuster的分享
发布2022-03-29 14:40:46
5500
发布2022-03-29 14:40:46
举报
文章被收录于专栏:johnhuster

运行环境:

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部分代码:

代码语言:javascript
复制
        # Migrate all the keys from source to target using the MIGRATE command
         while true
             keys = source.r.cluster("getkeysinslot",slot,o[:pipeline])
             break if keys.length == 0
             begin
                 source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:keys,*keys])
             rescue => e
                 if o[:fix] && e.to_s =~ /BUSYKEY/
                     xputs "*** Target key exists. Replacing it for FIX."
                     source.r.client.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:replace,:keys,*keys])
 

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

代码语言:javascript
复制
        # Migrate all the keys from source to target using the MIGRATE command
         while true
             keys = source.r.cluster("getkeysinslot",slot,o[:pipeline])
             break if keys.length == 0
             begin
                 source.r.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:keys,*keys])
             rescue => e
                 if o[:fix] && e.to_s =~ /BUSYKEY/
                     xputs "*** Target key exists. Replacing it for FIX."
                     source.r.call(["migrate",target.info[:host],target.info[:port],"",0,@timeout,:replace,:keys,*keys])

参考文章:

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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/08/13 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 Redis
腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档