diff options
| author | byte2016 <[email protected]> | 2018-08-28 14:56:56 +0800 |
|---|---|---|
| committer | byte2016 <[email protected]> | 2018-08-28 14:56:56 +0800 |
| commit | 067d4e6786f7f63fb6bb1b1136cad074675ed70b (patch) | |
| tree | ad2c0ed58cd6a9c6790d4b6d7e48f98bc0b16f87 /redis-node/build_cluster.sh | |
Diffstat (limited to 'redis-node/build_cluster.sh')
| -rw-r--r-- | redis-node/build_cluster.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/redis-node/build_cluster.sh b/redis-node/build_cluster.sh new file mode 100644 index 0000000..7cca323 --- /dev/null +++ b/redis-node/build_cluster.sh @@ -0,0 +1,29 @@ +#./redis-trib.rb 10.0.6.240:9012 10.0.6.240:9013 10.0.6.240:9014 10.0.6.240:9015 10.0.6.240:9016 10.0.6.240:9017 10.0.6.240:9018 10.0.6.240:9019 10.0.6.240:9020 10.0.6.240:9021 10.0.6.240:9022 10.0.6.240:9023 10.0.6.240:9024 10.0.6.240:9025 10.0.6.240:9026 10.0.6.240:9027 +#!/bin/bash +#!/bin/bash +if [ $# -lt 1 ];then + echo -e "usage:\n\tbuild_cluster.sh redis_instance_num\nexample:\n\tbuild_cluster.sh 16" + exit 1 +fi +((n = $1)) +slot_num=16384 +s=9001 +host=127.0.0.1 +#redis-cli -p $s -c +m=`expr $slot_num / $n` +echo "m value:"$m +for((i=1;i<$n;i++)); +do + ((p=$s+$i)) + #echo "i value:"$i + redis-cli -h $host -p $s -c cluster meet 127.0.0.1 $p >>/dev/null +done +for((i=0;i<$n;i++)) +do + ((p=$s+$i)) + for((j=$i*m;j<($i+1)*m;j++)) + do + #echo "j value":$j + redis-cli -h $host -p $p cluster addslots $j >>/dev/null + done +done |
