user1187968
user1187968

Reputation: 7986

AWS Redis Cluster - MOVE error

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'})

Upvotes: 16

Views: 28562

Answers (3)

Nae
Nae

Reputation: 15315

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.

Upvotes: 0

Muhammad Soliman
Muhammad Soliman

Reputation: 23756

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

Upvotes: 34

Mobility
Mobility

Reputation: 3305

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.

Upvotes: 1

Related Questions