安装包含脚本链接 (提取码:1314)
cd /home/summer/redis-5.0.8/utils/create-cluster
./create-cluster start
./create-cluster stop
./create-cluster clean
#!/bin/bash
# Settings
PORT=26999
TIMEOUT=2000
NODES=2
REPLICAS=1
reids_pwd=summerking
ip=$(ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:")
# Computed vars
ENDPORT=$((PORT+NODES))
if [ "$1" == "start" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Starting $PORT"
/home/summer/redis-5.0.8/src/redis-server --port $PORT --bind $ip --masterauth $reids_pwd --requirepass $reids_pwd --protected-mode no --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes
done
exit 0
fi
if [ "$1" == "stop" ]
then
while [ $((PORT < ENDPORT)) != "0" ]; do
PORT=$((PORT+1))
echo "Stopping $PORT"
/home/summer/redis-5.0.8/src/redis-cli -a $reids_pwd -h $ip -p $PORT shutdown nosave
done
kill -9 $(ps -ef | grep redis | grep -v grep | awk '{print $2}')
exit 0
fi
if [ "$1" == "clean" ]
then
cd /home/summer/redis-5.0.8/utils/create-cluster
rm -rf *.log
rm -rf appendonly*.aof
rm -rf dump*.rdb
rm -rf nodes*.conf
exit 0
fi