Docker中简单部署redis集群

1、创建一个自己的网卡

docker network create redis --subnet 192.167.0.0/24

2、脚本创建集群

for port in {port}/conf
touch /mydata/redis/node-{port}/conf/redis.conf
port 6379
bind 0.0.0.0
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-announce-ip 192.167.0.1${port}
cluster-announce-port 6379
cluster-announce-bus-port 16379
appendonly yes
EOF
done

image.png

接着启动6个redis
for port in {port}:6379 -p 1637{port}
-v /mydata/redis/node-{port}/conf/redis.conf:/etc/redis/redis.conf
-d --net redis --ip 192.167.0.1${port} redis redis-server /etc/redis/redis.conf;
done

接着随便进入一个redis容器
docker exec -it redis-1 /bin/sh

创建redis集群
redis-cli --cluster create 192.167.0.11:6379 192.167.0.12:6379 192.167.0.13:6379 192.167.0.14:6379 192.167.0.15:6379 192.167.0.16:6379 --cluster-replicas 1

你可能感兴趣的:(Docker中简单部署redis集群)