Created
May 23, 2019 15:14
-
-
Save pohzipohzi/7e304d6f5df916d43ad432b572f4eddd 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