Created
July 6, 2021 08:21
-
-
Save zaherg/49134bbf94b26e48b85f6e6aa272179c to your computer and use it in GitHub Desktop.
simple bash script to start a 6-node redis cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PORTS=($(seq 7001 1 7006)) | |
# set up servers | |
rm -f appendonly.aof | |
rm -f dump.rdb | |
for i in ${PORTS[@]} | |
do | |
rm -rf $i | |
mkdir $i | |
touch $i/redis.conf | |
touch $i/nodes.conf | |
echo "port $i | |
cluster-enabled yes | |
cluster-config-file $i/nodes.conf | |
cluster-node-timeout 5000 | |
appendonly yes" >> $i/redis.conf | |
done | |
# set up individual redis | |
tmux new-session -s rc -d | |
for i in ${PORTS[@]} | |
do | |
tmux send-keys "redis-server ./$i/redis.conf" Enter | |
tmux split-window -h | |
tmux select-layout tiled | |
done | |
# set up redis cluster | |
CMD="redis-cli --cluster create" | |
for i in ${PORTS[@]}; do CMD+=" 127.0.0.1:$i"; done | |
CMD+=" --cluster-replicas 1" | |
tmux send-keys "$CMD" Enter | |
# attach session | |
tmux -2 attach-session -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment