Skip to content

Instantly share code, notes, and snippets.

@pmirshad
Forked from fredead/Redis notes
Created June 9, 2023 10:33
Show Gist options
  • Save pmirshad/4d3da17d0b7ad1a8b17045a1b2fbd499 to your computer and use it in GitHub Desktop.
Save pmirshad/4d3da17d0b7ad1a8b17045a1b2fbd499 to your computer and use it in GitHub Desktop.
Automating creation of a redis cluster
Fireup all our nodes.
I could find information about this only which was odd. The tutorial is nice if you are setting up some static site ala the early 00's.
So this is some notes on creating a cluster by hang which will feed into the creation of a puppet / ansible / chef / shell / slat script
to do the main part of creating the cluster.
I note also many clients do not support redis in cluster mode WTF?
Open up this in a browser
https://redis.io/commands/cluster-slots
http://download.redis.io/redis-stable/src/redis-trib.rb -- The only documentation that seem to exist on how to do this
for node in list of nodes
connect to first cluster
redis-cli cluster meet <IP> <PORT>
redis-cli cluster nodes | gep connected # should show all nodes from above
# Connect to defined slaves an run fom the master id som e cluster nodes
for node in list of slaves
connect to node
CLUSTER REPLICATE <master id>
number per node = 16384/no,_masters
start = 0
limit = start + number per node
end = 16384
for node in list of master
connect to node
CLUSTER ADDSLOTS start start+1 ... limit
start = limit+1
limit = limit + number per node
if limit > end { limit = end }
# Technically its not clear is this is required
x=1
for each node
connect to node
CLUSTER SET-CONFIG-EPOCH x++
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment