Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'})
like image 477
user1187968 Avatar asked Jan 12 '18 19:01

user1187968


People also ask

Can't connect to Redis?

Firewall restriction is another common reason that can trigger the “could not connect to Redis connection refused”. By default Redis server listen to the TCP port 6379. If another application is using the port or if the firewall restrictions blocks the port, it can trigger the connection refused error.

Does Redis cluster use consistent hashing?

Redis Cluster data shardingRedis Cluster does not use consistent hashing, but a different form of sharding where every key is conceptually part of what we call a hash slot. There are 16384 hash slots in Redis Cluster, and to compute the hash slot for a given key, we simply take the CRC16 of the key modulo 16384.

Can you apply clustering and replication together in Redis?

Cross replication simply means that you don't have dedicated nodes for replicas, you just replicate the data to the next node. This way you save on the cluster size – you can make a Redis cluster with 2 replicas on 3 nodes instead of 9.


1 Answers

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
like image 194
Muhammad Soliman Avatar answered Sep 18 '22 23:09

Muhammad Soliman