11

I have setup up Redis master slave configuration having one master (6379 port) and 3 slaves (6380,6381,6382) running in the same machine. Looks like cluster is setup properly as I can see the following output on running info command:

# Replication
role:master
connected_slaves:3
slave0:ip=127.0.0.1,port=6380,state=online,offset=29,lag=1
slave1:ip=127.0.0.1,port=6381,state=online,offset=29,lag=1
slave2:ip=127.0.0.1,port=6382,state=online,offset=29,lag=1
master_repl_offset:43
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:42

But wherever I try to add new key in master, I get the following error:

(error) CLUSTERDOWN Hash slot not served

Using redis-3.0.7 in Mac OS X Yosemite.

Rakesh Goyal
  • 3,117
  • 8
  • 39
  • 69
  • what do you get when you run `redis-cli -p 6379 cluster nodes` ? , it seams that one of the hash slots is not assigned, which makes the whole cluster go down. – Rabea Mar 21 '16 at 15:08
  • Have you ever solved that? – Eduardo Feb 13 '17 at 14:35

5 Answers5

11

I had the same issue, turned out I forgot to run the create cluster:

cd /path/to/utils/create-cluster 
./create-cluster create

http://redis.io/topics/cluster-tutorial#creating-a-redis-cluster-using-the-create-cluster-script

luiscla27
  • 4,956
  • 37
  • 49
roboslone
  • 2,847
  • 3
  • 20
  • 28
7

To fix slots issue while insertion:

redis-cli --cluster fix localhost:6379
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Abdul Saqib
  • 129
  • 1
  • 4
1

You can use ruby script buddled with redis for creating clusters as mentioned below :

/usr/local/redis-3.2.11/src/redis-trib.rb create --replicas  1 192.168.142.128:7001  192.168.142.128:7002 192.168.142.128:7003  192.168.142.128:7004  192.168.142.128:7005 192.168.142.128:7006
yi meng
  • 19
  • 2
1

There is a hash slot not allotted to any master. Check the hash slots by looking at the column 9 in the output of following command (column 9 will be empty if no hash slots for that node):

redis-cli -h masterIP -p masterPORT CLUSTER NODES

The hash slots can be allotted by using the following command.

redis-cli -h masterIP -p masterPORT CLUSTER ADDSLOTS SLOTNNUMBER

But this has to be done for every slot number individually without missing. Use a bat script to include it in for loop. something like,

for /L %a in (0,1,5400) Do redis-cli -h 127.0.0.1 -p 7001  cluster addslots %a

Also, this command works before assigning slaves to master. After this ADDSLOTS step and completing the setup, the SET and GET worked fine. Remember to use -c along with redis-cli before SET to enable cluster support.

0

The issue comes when one or more Redis nodes gets corrupted and can no longer serve its configured hash slots.

You will have to bootstrap the cluster again to make sure the nodes agree on the hash slots to serve.

If the Redis nodes contain data or a key in the database 0, you will have to clear this data before rerunning the bootstrap.

Margach Chris
  • 1,404
  • 12
  • 20