redis on windows cluster setup

10,051

Solution 1

You can follow the Redis Cluster Tutorial and to create the cluster you can use the redis-trib.rb ruby script, for which you need to install Ruby for Windows.

For example:

> C:\Ruby22\Bin\ruby.exe redis-trib.rb create --replicas 1 192.168.1.1:7000 192.168.1.1:7001 192.168.1.1:7002 192.168.1.1:7003 192.168.1.1:7004 192.168.1.1:7005

Solution 2

Did not have the option to install Ruby on Windows but found the manual steps worked for me. The Ruby script seems to do a lot of checking stuff is setup correctly and is the preferred setup route. So Beware, here be dragons.

Set each node to run in Cluster mode. Edit the redis.windows-service.conf file and uncomment

cluster-enabled yes
cluster-config-file nodes-6379.conf
cluster-node-timeout 15000

restart the service.

Run a powershell window and change to the Redis installed folder and start the redis-cli. e.g.

cd "C:\Program Files\Redis"
.\redis-cli.exe

Now you can join other nodes. Run CLUSTER MEET IPADDRESS PORT for each of the other nodes, than the instance you happen to be on. e.g.

CLUSTER MEET 10.10.0.2 6379

After a few seconds running

CLUSTER NODES

Should list all the nodes connected, but all will be set as MASTER.

On each of the other nodes, run CLUSTER REPLICATE MASTERNODEID. Where MASTERNODEID is the hash-looking value next the node declared "myself" on your master when running CLUSTER NODES. e.g.

CLUSTER REPLICATE b7c767ab3ab7c4a926ac2fed937cf140b96764a7

Now allocate slots to each Master. My setup has three instances, only one master.

for ($slot=0;$slot -le 16383;$slot++) {
    .\redis-cli.exe -h REDMST CLUSTER ADDSLOTS $slot
}

Reconnect with redis-cli and try and save data. e.g.

SET foo bar
OK
GET foo
"bar"

Phew! Got most this from reading https://www.javacodegeeks.com/2015/09/redis-clustering.html#InstallingRedis which is not Windows specific.

Share:
10,051
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I have downloaded MSOpenTech Redis version 3.x which includes the long awaited clustering feature. My redis database is all working and I can start my cluster on the min 3 nodes required (in cluster mode). Does anyone know how to configure the cluster (it seems no one knows)? Installing Linux and running the native Linux version is not an option for me sadly. Any help would be greatly appreciated.

  • AlexS
    AlexS almost 8 years
    It is complaining : 55:in `require': cannot load such file -- redis (LoadError) Any suggestion?
  • uxp
    uxp almost 8 years
    @Woland You'll have to install the Redis Ruby Gem. You might have to search for the proper path to gem.exe, but as an Admin, run C:\Ruby22\Bin\gem.exe install redis
  • truekiller
    truekiller about 6 years
    After updating the redis.windows-service.conf file and then stoping and starting the redis server, it always says "Running in standalone mode".
  • truekiller
    truekiller about 6 years
    when i run D:\Coding\Redis>redis-server.exe redis.windows.conf , console goes to sleep. Nothing happens , as if it is waiting for some instruction.