Docker-compose redis cluster

方式1:Grokzen/docker-redis-cluster

clone Github docker-redis-cluster 项目。

Docker-compose redis cluster_第1张图片
image.png

构建指定版本的镜像

docker-compose build --build-arg "redis_version=3.2.10" redis-cluster

提示构建成功

Successfully built 12661f0ad176
Successfully tagged docker-redis-cluster_redis-cluster:latest

启动

export REDIS_CLUSTER_IP=0.0.0.0
docker-compose up -d

docker ps
CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                                                                          NAMES
8a62bbbe151a        docker-redis-cluster_redis-cluster   "/docker-entrypoint.…"   22 seconds ago      Up 20 seconds       0.0.0.0:5000-5002->5000-5002/tcp, 0.0.0.0:7000-7007->7000-7007/tcp, 6379/tcp   docker-redis-cluster_redis-cluster_1

docker-compose down 关闭集群。
也可以执行 make up 启动容器。

测试一下

$ ./redis-cli -c -p 7000
127.0.0.1:7000> set name andy
-> Redirected to slot [5798] located at 127.0.0.1:7001
OK
127.0.0.1:7001> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:2
cluster_stats_messages_sent:536
cluster_stats_messages_received:536
127.0.0.1:7001> cluster nodes
b832a137af3acad96b12d7609a155c57aac88f54 127.0.0.1:7000 master - 0 1547128288045 1 connected 0-5460
4d5b7d9652d36fc914cdbe8711faa0f3cf4ba8c6 127.0.0.1:7003 slave b832a137af3acad96b12d7609a155c57aac88f54 0 1547128289053 4 connected
d94d928dd6fe769d8195269dd85e3fc97f62f686 127.0.0.1:7002 master - 0 1547128287541 3 connected 10923-16383
6adf2d225d7a9bd44e3173d60861a6aee560f2ea 127.0.0.1:7004 slave ec4c3f76e747661f1ecdcd62efb31144bcb35c27 0 1547128287541 5 connected
9c377062c93520f66774118a8f021509ae6e0bfc 127.0.0.1:7005 slave d94d928dd6fe769d8195269dd85e3fc97f62f686 0 1547128289557 6 connected
ec4c3f76e747661f1ecdcd62efb31144bcb35c27 127.0.0.1:7001 myself,master - 0 0 2 connected 5461-10922

Fatal error, can't open config file '/redis-conf/sentinel-7000.conf'

docker-compose down
docker-compose up -d

方式2:手动 docker-compose

Redis-Cluster集群
Docker方式部署redis-cluster
如何用docker部署redis cluster
docker-compose组建带密码redis集群 完整版

卡在 Waiting for the cluster to join....

set时同步节点失败

你可能感兴趣的:(Docker-compose redis cluster)