mirror of
https://github.com/fluencelabs/redis
synced 2025-03-31 23:01:03 +00:00
create-cluster script added.
Simple shell script to create / destroy Redis clusters for manual testing.
This commit is contained in:
parent
d3ef6c94bf
commit
8899f91a7f
utils/create-cluster
27
utils/create-cluster/README
Normal file
27
utils/create-cluster/README
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Create-custer is a small script used to easily start a big number of Redis
|
||||||
|
instances configured to run in cluster mode. Its main goal is to allow manual
|
||||||
|
testing in a condition which is not easy to replicate with the Redis cluster
|
||||||
|
unit tests, for example when a lot of instances are needed in order to trigger
|
||||||
|
a give bug.
|
||||||
|
|
||||||
|
The tool can also be used just to easily create a number of instances in a
|
||||||
|
Redis Cluster in order to experiment a bit with the system.
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
---
|
||||||
|
|
||||||
|
To create a cluster, follow this steps:
|
||||||
|
|
||||||
|
1. Edit create-cluster and change the start / end port, depending on the
|
||||||
|
number of instances you want to create.
|
||||||
|
2. Use "./create-cluster start" in order to run the instances.
|
||||||
|
3. Use "./create-cluster create" in order to execute redis-trib create, so that
|
||||||
|
an actual Redis cluster will be created.
|
||||||
|
4. Now you are ready to play with the cluster. AOF files and logs for each instances are created in the current directory.
|
||||||
|
|
||||||
|
In order to stop a cluster:
|
||||||
|
|
||||||
|
1. Use "./craete-cluster stop" to stop all the instances. After you stopped the instances you can use "./create-cluster start" to restart them if you change ideas.
|
||||||
|
2. Use "./create-cluster clean" to remove all the AOF / log files to restat with a clean environment.
|
||||||
|
|
||||||
|
It is currently hardcoded that you start a cluster where each master has one slave, since the script is pretty basic.
|
66
utils/create-cluster/create-cluster
Executable file
66
utils/create-cluster/create-cluster
Executable file
@ -0,0 +1,66 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PORT=30000
|
||||||
|
ENDPORT=30006
|
||||||
|
|
||||||
|
if [ "$1" == "start" ]
|
||||||
|
then
|
||||||
|
while [ $((PORT < ENDPORT)) != "0" ]; do
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
echo "Starting $PORT"
|
||||||
|
../../src/redis-server --port $PORT --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout 5 --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "create" ]
|
||||||
|
then
|
||||||
|
HOSTS=""
|
||||||
|
while [ $((PORT < ENDPORT)) != "0" ]; do
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
HOSTS="$HOSTS 127.0.0.1:$PORT"
|
||||||
|
done
|
||||||
|
../../src/redis-trib.rb create --replicas 1 $HOSTS
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "stop" ]
|
||||||
|
then
|
||||||
|
while [ $((PORT < ENDPORT)) != "0" ]; do
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
echo "Stopping $PORT"
|
||||||
|
redis-cli -p $PORT shutdown nosave
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "join" ]
|
||||||
|
then
|
||||||
|
while [ $((PORT < ENDPORT)) != "0" ]; do
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
echo "Joining $PORT"
|
||||||
|
redis-cli -p $PORT CLUSTER MEET 127.0.0.1 10002
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Waiting 5 seconds"
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
PORT=30000
|
||||||
|
while [ $((PORT < ENDPORT)) != "0" ]; do
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
echo "Replicate $PORT"
|
||||||
|
redis-cli -p $PORT CLUSTER REPLICATE $2
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "clean" ]
|
||||||
|
then
|
||||||
|
rm -rf *.log
|
||||||
|
rm -rf appendonly*.aof
|
||||||
|
rm -rf dump*.rdb
|
||||||
|
rm -rf nodes*.conf
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Usage: $0 [start|create|stop|join|clean]"
|
Loading…
x
Reference in New Issue
Block a user