docker搭建redis集群,超级简单方便。文章来源:https://www.toymoban.com/news/detail-624182.html
# 1. 拉取redis. 目前我拉取最新的是7.0.12
docker pull redis
# 2. 下载配置文件
wget https://raw.githubusercontent.com/redis/redis/7.0/redis.conf
# 3. 移到对应目录
mkdir -p /opt/docker/redis
mv redis.conf /opt/docker/redis/
# 4. 启动(3主3从)
docker run -it -d --name redis01 -v /opt/docker/redis:/etc/redis -p 36379:6379 redis redis-server /etc/redis/redis.conf
docker run -it -d --name redis02 -v /opt/docker/redis:/etc/redis -p 36380:6379 redis redis-server /etc/redis/redis.conf
docker run -it -d --name redis03 -v /opt/docker/redis:/etc/redis -p 36381:6379 redis redis-server /etc/redis/redis.conf
docker run -it -d --name redis04 -v /opt/docker/redis:/etc/redis -p 36382:6379 redis redis-server /etc/redis/redis.conf
docker run -it -d --name redis05 -v /opt/docker/redis:/etc/redis -p 36383:6379 redis redis-server /etc/redis/redis.conf
docker run -it -d --name redis06 -v /opt/docker/redis:/etc/redis -p 36384:6379 redis redis-server /etc/redis/redis.conf
# docker rm redis01 redis02 redis03
# 5. 查看ip
docker inspect redis01 | grep IPAddress
docker inspect redis02 | grep IPAddress
docker inspect redis03 | grep IPAddress
docker inspect redis04 | grep IPAddress
docker inspect redis05 | grep IPAddress
docker inspect redis06 | grep IPAddress
# docker stop redis01 redis02 redis03 redis04 redis05 redis06
# 6. 启动容器
docker start redis01 redis02 redis03 redis04 redis05 redis06
# 7. 进入redis, 并配置集群
docker exec -it redis01 /bin/bash
redis-cli --cluster create 172.17.0.2:6379 172.17.0.3:6379 172.17.0.4:6379 172.17.0.5:6379 172.17.0.6:6379 172.17.0.7:6379 --cluster-replicas 1
参考文章:文章来源地址https://www.toymoban.com/news/detail-624182.html
- Redis 集群搭建详细指南
- 基于Docker的Redis集群搭建
- redis: (error) CLUSTERDOWN The cluster is down
- Redis cluster集群模式的原理解析
到了这里,关于【redis】docker搭建redis集群的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!