Skip to content

Instantly share code, notes, and snippets.

@hbprotoss
Last active April 14, 2016 08:39
Show Gist options
  • Save hbprotoss/6271004e1f9da186c54ed58acd8d2d8c to your computer and use it in GitHub Desktop.
Save hbprotoss/6271004e1f9da186c54ed58acd8d2d8c to your computer and use it in GitHub Desktop.
redis cluster
#!/bin/bash
START_PORT=7100
COUNT=6
for port in $(seq $START_PORT `expr $START_PORT + $COUNT - 1`)
do
dir="`pwd`/$port"
mkdir $dir
conf_file="$dir/$port.conf"
cat > $conf_file << EOF
daemonize yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
pidfile $port.pid
port $port
logfile "$dir/$port.log"
dbfilename $port.rdb
dir $dir
appendonly yes
appendfilename "$port.aof"
EOF
done
#!/bin/bash
START_PORT=7100
COUNT=6
nodes=""
for port in $(seq $START_PORT `expr $START_PORT + $COUNT - 1`)
do
nodes+=" 127.0.0.1:$port"
redis-server "$port/$port.conf"
done
nodes=${nodes:1}
redis-trib.rb create --replicas 1 $nodes
#!/bin/bash
START_PORT=7100
COUNT=6
for port in $(seq $START_PORT `expr $START_PORT + $COUNT - 1`)
do
redis-cli -p $port shutdown
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment