redis-cli connection using command prompt error (error) MOVED 5798 192.168.3.111:9001 solution

created at 07-22-2021 views: 26

Redis cluster redis-cli connection using command prompt error (error) MOVED 5798 192.168.3.111:9001

Error details:

user@user-70DGA014CN:~/redis-cluster$ redis-cli -p 9000
127.0.0.1:9000> set name chenxinming
(error) MOVED 5798 127.0.0.1:9001

1st solution

just change to port 9001

user@user-70DGA014CN:~/redis-cluster$ redis-cli -p 9001
127.0.0.1:9001> set name chenxinming
OK
127.0.0.1:9001>The final solution:

2nd solution

>>> redis-cli -c -h 192.168.3.99 -p 9000

127.0.0.1:9002> set foo bar
OK
127.0.0.1:9002> set hello world
-> Redirected to slot [866] located at 127.0.0.1:9000
OK
127.0.0.1:9000> get foo
-> Redirected to slot [12182] located at 127.0.0.1:9002
"bar"
127.0.0.1:9002> get hello
-> Redirected to slot [866] located at 127.0.0.1:9000
"world"

Careful observation revealed that redis-cli kept redirecting and jumping between 9000 and 9002 according to the instructions. If you do not add the -c option at startup, you will see the MOVED redirection message error message

user@user-70DGA014CN:~/redis-cluster$ redis-cli -p 9000
127.0.0.1:9000> set name chenxinming
(error) MOVED 5798 127.0.0.1:9001
created at:07-22-2021
edited at: 07-22-2021: