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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章