How to setup a redis cluster on Windows without bash and ruby (a.k.a. rewrite utils/create-cluster.sh and src/redis-trib.rb)

3,088 views
Skip to first unread message

Goran Pušić

unread,
May 13, 2016, 9:06:30 AM5/13/16
to Redis DB
Hi all,

I am trying to create a Redis cluster on Windows, but without using utils/create-cluster.sh and src/redis-trib.rb (reason: I will have a *really* hard time getting e.g. cygwin and Ruby to production servers, I think it is easier to do that part alone).

At the moment, I am deciphering redis-trib.rb, but can someone point me to the right direction?

I think that I need to get "cluster addslots", "cluster meet" and more, but I am struggling.

TIA, Goran.

CharSyam

unread,
May 13, 2016, 9:46:39 AM5/13/16
to redi...@googlegroups.com
Unfortunately redis doesn't support on windows officially

2016년 5월 13일 금요일, Goran Pušić<goran...@gmail.com>님이 작성한 메시지:
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Goran Pušić

unread,
May 13, 2016, 10:26:18 AM5/13/16
to Redis DB
ERRATA: it should say "I need to get "cluster addslots", "cluster meet" and more *to work*..."

Enrico Giordani

unread,
May 13, 2016, 11:02:45 AM5/13/16
to Redis DB
Hi Goran,
have you already read the documentation to configure the cluster manually?


On Friday, May 13, 2016 at 3:06:30 PM UTC+2, Goran Pušić wrote:

Tuco

unread,
May 14, 2016, 4:13:37 AM5/14/16
to Redis DB
Hi, 

Lets say you are trying to configure 3 masters, after your three masters are up in cluster mode(individually), then you should execute the following on command line.

redis-cli -c -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7001
redis-cli -c -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7002

The above will allow the three nodes to meet. Then the below

for slot in {0..5461}; do redis-cli -h 127.0.0.1 -p 7000 CLUSTER ADDSLOTS $slot; done;
for slot in {5462..10923}; do redis-cli -h 127.0.0.1 -p 7001 CLUSTER ADDSLOTS $slot; done;
for slot in {10924..16383}; do redis-cli -h 127.0.0.1 -p 7002 CLUSTER ADDSLOTS $slot; done;

this will assign them the slots.

That is it. You should see the cluster info command to check that everything is fine.
If there are different no of nodes, your calculation will be a bit diff(like for 2 nodes, it will be 0..8191, 8192..16383), but the procedure will be the same

Also, the above is for masters only,
If you want to further add slaves(lets say 7003 as slave of 7000, 7004 as slave of 7001, 7005 as slave of 7002), then do the following after starting 7003,7004,7005 individually.

redis-cli -c -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7003
redis-cli -c -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7004
redis-cli -c -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7005

redis-cli -c -h 127.0.0.1 -p 7003 cluster replicate <node_id_of_7000>
redis-cli -c -h 127.0.0.1 -p 7004 cluster replicate <node_id_of_7001>
redis-cli -c -h 127.0.0.1 -p 7005 cluster replicate <node_id_of_7002>

You can find the <node_id_of_7000> etc from cluster nodes command by doing redis-cli -c -h 127.0.0.1 -p 7000 cluster nodes

Goran Pušić

unread,
May 17, 2016, 9:13:49 AM5/17/16
to Redis DB
Got the trivial cluster without replica nodes running.

I did not understand that I needed to add slots to cover the complete key partitioning rate.

For info, "DOS" batch command to add slots is e.g.

for /l %%s in (0, 1, 5461) do redis-cli -h 127.0.0.1 -p 7000 CLUSTER ADDSLOTS %%s


Many thanks!

Goran.

Luca Dell'Angelo

unread,
Dec 13, 2016, 9:20:50 AM12/13/16
to Redis DB
Hi Everyone,

I configured redis on windows in cluster mode (two masters for the sake of semplicity), started them  (picture in attachment) and added slots as suggested by Goran but

when i try to access to a redis db key by client api I get the exception: "CLUSTERDOWN The cluster is down". 

Any suggestions, please?

The code i'm using:

using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("127.0.0.1:7000,127.0.0.1:7001,allowAdmin=true,connectTimeout=90000"))

            {
                var res = redis.GetStatus();
                IDatabase db = redis.GetDatabase();
                var result = db.StringGet("luca");//Here i get the exception
            }



Thanks
redis.png

Luca Dell'Angelo

unread,
Dec 13, 2016, 10:19:02 AM12/13/16
to Redis DB
It works! I forgot to run: 

redis-cli -c -h 127.0.0.1 -p 7000 cluster meet 127.0.0.1 7001

after restart redis servers -.-'
Reply all
Reply to author
Forward
0 new messages