谷粒商城创建Redis集群(二十五)

所有的命令如下:

for port in $(seq 7001 7006);  \
do \
mkdir -p /mydata/redis/node-${port}/conf
touch /mydata/redis/node-${port}/conf/redis.conf
cat << EOF > /mydata/redis/node-${port}/conf/redis.conf
port ${port}
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-announce-ip 192.168.1.119
cluster-announce-port ${port}
cluster-announce-bus-port 1${port}
appendonly yes
EOF
docker run -p ${port}:${port} -p 1${port}:1${port} --name redis-${port}  \
-v /mydata/redis/node-${port}/data:/data \
-v /mydata/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \
-d redis:5.0.7 redis-server /etc/redis/redis.conf; \
done



docker exec -it redis-7001 bash 
redis-cli  --cluster create 192.168.1.119:7001 192.168.1.119:7002 192.168.1.119:7003 192.168.1.119:7004 192.168.1.119:7005 192.168.1.119:7006
  --cluster-replicas 1

 创建集群的图如下:

 

 演示故障的上下线

 

posted @ 2020-06-26 00:50  天宇轩-王  阅读(318)  评论(0编辑  收藏  举报