Created
February 13, 2023 23:32
-
-
Save nicksherron/3b59dac1c5bc562d12874df0ffcca87a to your computer and use it in GitHub Desktop.
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
#/usr/bin/env bash | |
# start redis cluster using tmux | |
function create_redis_cluster { | |
mkdir cluster-test | |
cd cluster-test | |
mkdir 7001 7002 7003 7004 7005 7006 || true | |
# create redis cluster | |
for port in 7001 7002 7003 7004 7005 7006 | |
do | |
echo "port $port" > $port/redis.conf | |
echo "cluster-enabled yes" >> $port/redis.conf | |
echo "cluster-config-file nodes.conf" >> $port/redis.conf | |
echo "cluster-node-timeout 5000" >> $port/redis.conf | |
echo "appendonly yes" >> $port/redis.conf | |
done | |
# start redis cluster using tmux | |
for port in 7001 7002 7003 7004 7005 7006 | |
do | |
tmux kill-session -t $port || true | |
tmux new-session -d -s $port | |
tmux send-keys -t $port "cd $port" C-m | |
tmux send-keys -t $port "redis-server ./redis.conf" C-m | |
done | |
# create cluster | |
redis-cli --cluster create 127.0.0.1:7001 127.0.0.1:7002 \ | |
127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006 \ | |
--cluster-replicas 1 | |
} | |
create_redis_cluster | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment