Docker安装Redis Cluster 三主三从

1. 主机配置:

10.21.14.164,10.21.14.165,10.21.14.166

2. 端口配置

6381,6382

3. 6381的redis.conf配置

port 6381

protected-mode no

pidfile /var/run/redis_6381.pid

appendonly yes

cluster-enabled yes

cluster-config-file nodes-6381.conf

cluster-node-timeout 15000

4. 6382的redis.conf配置

port 6382

protected-mode no

pidfile /var/run/redis_6382.pid

appendonly yes

cluster-enabled yes

cluster-config-file nodes-6382.conf

cluster-node-timeout 15000

5. 三台主机分别新建目录并将redis.conf放入

/app/redis/cluster/6381/data, /app/redis/cluster/6382/data

6. 三台主机启动Redis

docker run -v /app/redis/cluster/6381/data/:/data --privileged=true --net host --name redis-6381 -d redis:latest redis-server /data/redis.conf

docker run -v /app/redis/cluster/6382/data/:/data --privileged=true --net host --name redis-6382 -d redis:latest redis-server /data/redis.conf

7. 任选一个redis使用redis-cli创建集群

docker exec -it redis-6381 redis-cli --cluster create 10.21.14.164:6381 10.21.14.164:6382 10.21.14.165:6381 10.21.14.165:6382 10.21.14.166:6381 10.21.14.166:6382 --cluster-replicas 1

选择yes自动创建集群


你可能感兴趣的:(Docker安装Redis Cluster 三主三从)