summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-01-30 10:41:45 +0100
committerantirez <antirez@gmail.com>2015-01-30 10:41:45 +0100
commit6b1c6334bec4277b2c5cb8f04975deb22e8e3a58 (patch)
treea081b5975ec1b8228c9c9c13e08fe3a4fcf52ed3 /utils
parente5a22064cce137cb4897779050966a719dd4bdce (diff)
downloadredis-6b1c6334bec4277b2c5cb8f04975deb22e8e3a58.tar.gz
Cluster: create-cluster script improved.
Diffstat (limited to 'utils')
-rw-r--r--utils/create-cluster/README2
-rwxr-xr-xutils/create-cluster/create-cluster56
2 files changed, 43 insertions, 15 deletions
diff --git a/utils/create-cluster/README b/utils/create-cluster/README
index f3a3f0883..1f43748ee 100644
--- a/utils/create-cluster/README
+++ b/utils/create-cluster/README
@@ -24,4 +24,4 @@ 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.
+Use the command "./create-cluster help" to get the full list of features.
diff --git a/utils/create-cluster/create-cluster b/utils/create-cluster/create-cluster
index 76f61091d..efb3135d4 100755
--- a/utils/create-cluster/create-cluster
+++ b/utils/create-cluster/create-cluster
@@ -1,8 +1,21 @@
#!/bin/bash
+# Settings
PORT=30000
-ENDPORT=30006
-TIMEOUT=15000
+TIMEOUT=2000
+NODES=6
+REPLICAS=1
+
+# You may want to put the above config parameters into config.sh in order to
+# override the defaults without modifying this script.
+
+if [ -a config.sh ]
+then
+ source "config.sh"
+fi
+
+# Computed vars
+ENDPORT=$((PORT+NODES))
if [ "$1" == "start" ]
then
@@ -21,7 +34,7 @@ then
PORT=$((PORT+1))
HOSTS="$HOSTS 127.0.0.1:$PORT"
done
- ../../src/redis-trib.rb create --replicas 1 $HOSTS
+ ../../src/redis-trib.rb create --replicas $REPLICAS $HOSTS
exit 0
fi
@@ -35,22 +48,31 @@ then
exit 0
fi
-if [ "$1" == "join" ]
+if [ "$1" == "watch" ]
then
- while [ $((PORT < ENDPORT)) != "0" ]; do
- PORT=$((PORT+1))
- echo "Joining $PORT"
- redis-cli -p $PORT CLUSTER MEET 127.0.0.1 10002
+ PORT=$((PORT+1))
+ while [ 1 ]; do
+ clear
+ date
+ redis-cli -p $PORT cluster nodes | head -30
+ sleep 1
done
+ exit 0
+fi
- echo "Waiting 5 seconds"
- sleep 5
+if [ "$1" == "tail" ]
+then
+ INSTANCE=$2
+ PORT=$((PORT+INSTANCE))
+ tail -f ${PORT}.log
+ exit 0
+fi
- PORT=30000
+if [ "$1" == "call" ]
+then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
- echo "Replicate $PORT"
- redis-cli -p $PORT CLUSTER REPLICATE $2
+ ../../src/redis-cli -p $PORT $2 $3 $4 $5 $6 $7 $8 $9
done
exit 0
fi
@@ -64,4 +86,10 @@ then
exit 0
fi
-echo "Usage: $0 [start|create|stop|join|clean]"
+echo "Usage: $0 [start|create|stop|watch|tail|clean]"
+echo "start -- Launch Redis Cluster instances."
+echo "create -- Create a cluster using redis-trib create."
+echo "stop -- Stop Redis Cluster instances."
+echo "watch -- Show CLUSTER NODES output (first 30 lines) of first node."
+echo "tail <id> -- Run tail -f of instance at base port + ID."
+echo "clean -- Remove all instances data, logs, configs."