I figured out a good simple way myself.
Suppose we want to create the cluster as:
A1-S1
A2-S2
A3-S3
Where A is master and S are their corresponding slaves and this forms a single cluster. The steps would include.
- Write into
nodes.conf
before starting the redis instances to append the desired slot hashes after the connected
string. Make sure master and slave have the same slot hashes. Do this only for the line containing myself
. This will look something like this:
Earlier:
a252d572140fd2b5410d4a63d051f1e6613cfd1f :6379@16379 myself,slave 0 0 0 connected
Final:
a252d572140fd2b5410d4a63d051f1e6613cfd1f :6379@16379 myself,slave 0 0 0 connected 0-5500
After this start the redis instances.
- Now one by one do a cluster meet for each pair of master and slave. Do 3
cluster meet
each for A1, A2 and A3 for their corresponding slaves. This connects the master and slave.
- If by chance the master becomes a slave after a meet operation, do a
cluster failover
from the slave to make it the master.
- Finally, run 2 more
cluster meet
for A1-A2 and A2-A3.
Doing this you get a cluster of the config you need.