AWS Redis Cluster - MOVE error
Asked Answered
D

3

16

I try to execute a hmset command on AWS Redis Cluster, and I'm getting the following "moved" error. Not sure what is going on.

MOVED 7652 10.0.4.210:6379

from rediscluster import StrictRedisCluster

startup_nodes = [{"host": self.host, "port": self.port}]
client = StrictRedisCluster(startup_nodes=startup_nodes,
                                        decode_responses=True,
                                        skip_full_coverage_check=True)

client.hmset('my_key', {'abc':'123'})
Desmarais answered 12/1, 2018 at 19:4 Comment(3)
what's the value of self.port? is it 7652?Syllabogram
redis.io/topics/cluster-tutorial#playing-with-the-clusterCerys
In my case, I use a GUI client and I didn't start the connection with Cluster.Josie
B
34

As your data is sharded and distributed into different nodes in the cluster, you should use -c option to be able to connect to redis in cluster mode.

In your question, it is not known what type of client library you using, however the same concept, you need to use a library that supports cluster mode. Here is a list of client packages in nodejs

If you're trying to get data it will redirect you as a client to the correct shard/partition that holds the requested data.

if you have redis-cli, you can try this:

redis-cli -c -h {REDIS_HOST_OR_PORT} -p 6379 

if you have docker installed, you can connect to the cluster using the following:

docker run -ti --rm redis redis-cli -c -h {REDIS_HOST_OR_IP} -p 6379
Biak answered 26/10, 2018 at 1:35 Comment(1)
thank you. actually, the -c switch is the answer which switches to the cluster-mode.Fifth
C
1

The "MOVED" error happens when you connect to one node in a redis cluster with standalone mode, and data you query is on other nodes in the cluster.

I don't know how your StrictRedisCluster implenmented, but something is definitively wrong in this client.

Cormophyte answered 15/1, 2018 at 7:21 Comment(0)
T
0

For get commands you may want to run:

READONLY

first as one of the following might have happened:

  1. The client sent a command about hash slots never served by the master of this replica.
  2. The cluster was reconfigured (for example resharded) and the replica is no longer able to serve commands for a given hash slot.
Theurgy answered 22/8, 2022 at 8:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.