redis集群报错:(error) MOVED 的解决方法

用redis-cli进行数据操作报错(error) MOVED 的解决方法

报错示例:

(base) wdh@wdh:~$ redis-cli -h 172.17.0.1 -p 6391
172.17.0.1:6391> get name
(error) MOVED 5798 172.100.0.1:6392
172.17.0.1:6391> 

报错原因:

  • 没有用集群模式连接(连接节点命令 没有加 -c 参数)

解决办法:

  • 用 -c 参数连接redis集群节点:redis-cli -c -h 172.17.0.1 -p 6391
(base) wdh@wdh:~$ redis-cli -c -h 172.17.0.1 -p 6391
172.17.0.1:6391> get name
-> Redirected to slot [5798] located at 172.100.0.1:6392
(nil)
172.100.0.1:6392> set name 1
OK
172.100.0.1:6392> get name
"1"
172.100.0.1:6392> 

参考文章:

标题:redis集群报错:(error) MOVED 解决方法
地址:https://segmentfault.com/a/1190000020980650?utm_source=tag-newest
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章