背景
redis操作key时出现以下错误
(error) MOVED 5798 127.0.0.1:7001
原因
这种情况一般是因为启动redis-cli时没有设置集群模式所导致。
解决方案
启动时使用-c参数来启动集群模式,命令如下:
redis-cli -c -p 7000
测试
127.0.0.1:7000> get name
-> Redirected to slot [5798] located at 127.0.0.1:7001
(nil)
127.0.0.1:7001> set name cf
OK
127.0.0.1:7000> get name
-> Redirected to slot [5798] located at 127.0.0.1:7001
"cf"
本文介绍了解决Redis集群中出现的MOVED错误的方法。通常这种错误是由于未正确配置redis-cli客户端引起的。通过添加-c参数启动redis-cli即可解决该问题。

1万+

被折叠的 条评论
为什么被折叠?



