Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redis on windows cluster setup

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.

like image 683
NeilR Avatar asked Jan 05 '16 15:01

NeilR


People also ask

How do I connect to Redis cluster?

Open the Command Prompt and change to the Redis directory and run the command c:\Redis>redis-cli -h Redis_Cluster_Endpoint -p 6379 . Run Redis commands. You are now connected to the cluster and can run Redis commands like the following.

Can you run Redis on Windows?

You can install Redis cache on Windows 10 using Windows Subsystem for Linux(a.k.a WSL2). WSL2 is a compatibility layer for running Linux binary executables natively on Windows 10 and Windows Server 2019.


2 Answers

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
like image 149
thepirat000 Avatar answered Oct 11 '22 14:10

thepirat000


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.

like image 35
rob Avatar answered Oct 11 '22 13:10

rob