redis实战 migrate异常NOAUTH Authentication required.

时间:2022-07-23
本文章向大家介绍redis实战 migrate异常NOAUTH Authentication required.,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

当redis cluster集群设置密码的时候,使用migirate需要加上密码,否则会报如下异常:

(error) ERR Target instance replied with error: NOAUTH Authentication required.

redis在3.0之前是不支持migrate带有password的,在3.0之后可以在migrate中加入auth参数来做权限校验

127.0.0.1:6380> migrate 192.168.0.33 6380 "" 0 2000 auth mypassword keys user:{info}:age user:{info}:id
OK

注意不要把auth password放到最后面,否则migrate会将会auth mypassword都当做key,结果报出如下错误,该错误是说migrate要迁移的多个key不在同一个slot中

(error) CROSSSLOT Keys in request don't hash to the same slot