Reputation: 969
I want to create a redis cluster with only specific redis hosts being master and slave. Also I want to assign from myself which host should be replica of which master.
Currently, cluster-create
command creates a cluster when given a list of hostname:port
parameters in any one of the redis masters. But this does not let us provide a custom config as we require. It suggests us with what is will create, and we can approve or cancel (not edit).
Is there any simple way of achieving what I intend to do?
Upvotes: 0
Views: 613
Reputation: 969
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.
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.
cluster meet
each for A1, A2 and A3 for their corresponding slaves. This connects the master and slave. cluster failover
from the slave to make it the master.cluster meet
for A1-A2 and A2-A3.Doing this you get a cluster of the config you need.
Upvotes: 0