Setup Redis 3.2 Cluster based server in windows
Steps:
- Download Redis 3.2 Server windows from link: the MSOpenTech version
- extract of install above downloaded one.
- Create a folder redis3.2
- go to folder redis3.2
- create cluster node folders
eg: node1,node2, node3 - copy the redis-server.exe and redis-cli.exe into redis3.2 folder from Downloaded Redis zip/installation
- go to each node folder and create redis.conf file and add below content
1 2 3 4 5
port 6380 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes
- Now Run each node by going to each node folder with below command:
c:\node1>..\redis-server.exe redis.conf
c:\node2>..\redis-server.exe redis.conf
c:\node3>..\redis-server.exe redis.conf
After node started you will see below message
Redis 3.2.100 (00000000/0) 64 bit Running in cluster mode Port: 6380 PID: 7096
- Now connect any node with redis-cli.exe
redis-cli.exe -h <ip or host> -p 6380
- Run below command to make them join cluster:
CLUSTER MEET
6380 CLUSTER MEET 6381 CLUSTER MEET 6382 - after run CLUSTER NODES
you will see all nodes
sample output:
72b640cb92b054d51c89d0c28a016573e7ff3631 127.0.0.1:6380 myself,master
above first column is nodeid which is auto generated - Now all nodes are MASTER nodes
- now change node1 as master and rest as slaves
- connect to each node except master node via redis-cli and run below command
master-node-id is node id of node which you want as master.CLUSTER REPLICATE <master-node-id>
- Now you will see one master node and rest nodes are slaves
- Now allocate the slots to the master node with below command
FOR /L %i IN (0,1,16383) DO ( redis-cli.exe -p **6380** CLUSTER ADDSLOTS %i )
6380 is port of master node
Now Redis 3.2 cluster server is ready!
You can also Download the following pre setup Redis 3.2 cluster based server:
click here
Help:
- To connect Redis node with host/port via redis-cli interface use below command:
redis-cli -h hostname -p portnumber