Tuesday, June 12, 2018

Setup Redis 3.2 server in cluster mode in Windows 7 64 bit

Setup Redis 3.2 Cluster based server in windows


  1. Download Redis 3.2 Server windows from link: the MSOpenTech version
  2. extract of install above downloaded one.
  3. Create a folder redis3.2
  4. go to folder redis3.2 
  5. create cluster node folders
    eg: node1,node2, node3
  6. copy the redis-server.exe and redis-cli.exe into redis3.2 folder from Downloaded Redis zip/installation
  7. go to each node folder and create redis.conf file and add below content
    port 6380
    cluster-enabled yes
    cluster-config-file nodes.conf
    cluster-node-timeout 5000
    appendonly yes
    add the unique port number in each node for node1 6380 for node1 6381 for node1 6382
  8. 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
  9. Now connect any node with redis-cli.exe
    redis-cli.exe -h <ip or host> -p 6380
  10. Run below command to make them join cluster:
    CLUSTER MEET  6380
    CLUSTER MEET  6381
    CLUSTER MEET  6382
  11. after run CLUSTER NODES you will see all nodes
    sample output:
    72b640cb92b054d51c89d0c28a016573e7ff3631 myself,master
    above first column is nodeid which is auto generated
  12. Now all nodes are MASTER nodes
  13. now change node1 as master and rest as slaves
  14. connect to each  node except master node via redis-cli and run below command
    CLUSTER REPLICATE <master-node-id>
    master-node-id is node id of node which you want as master.
  15. Now you will see one master node and rest nodes are slaves
  16. 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

  • To connect Redis node with host/port via redis-cli interface use below command:
    redis-cli -h hostname -p portnumber

No comments:

Post a Comment