当前位置:网站首页>docker部署redis集群
docker部署redis集群
2022-06-27 02:09:00 【运维@小兵】
一、创建redis_cluster网桥
docker network create redis_cluster --subnet=172.38.1.0/24 -o com.docker.network.bridge.name=redis_cluster
ifconfig redis_cluster

二、启动六个容器
两个容器为一组,一个master,一个slave,master挂掉,slave会成为master
for port in $(seq 1 6); \
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 6379 bind 0.0.0.0 cluster-enabled yes #启动集群模式 cluster-config-file nodes.conf #集群节点信息文件 cluster-node-timeout 5000 #redis节点宕机被发现的时间 cluster-announce-ip 172.38.1.1${port} #集群节点的汇报ip,防止nat,此处为docker容器IP cluster-announce-port 6379 #集群节点的汇报port,防止nat cluster-announce-bus-port 16379 #集群节点的汇报bus-port,防止nat appendonly yes #开启aof持久化 EOF
# 通过脚本一次启动6个redis容器
docker run -p 637${port}:6379 -p 1637${port}:16379 --name redis-${port} \
-v /mydata/redis/node-${port}/data:/data \
-v /mydata/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \
-d --net redis_cluster --ip 172.38.1.1${port} redis:6.0 redis-server /etc/redis/redis.conf
done
三、创建集群
docker exec -it redis-1 bash
redis-cli --cluster create 172.38.1.11:6379 172.38.1.12:6379 172.38.1.13:6379 172.38.1.14:6379 172.38.1.15:6379 172.38.1.16:6379 --cluster-replicas 1
redis-cli -c #进入集群
cluster info #查看集群信息

cluster nodes

四、卸载集群
for port in $(seq 1 6); do docker rm -f redis-${port}; done
rm -rf /mydata/redis
五、参考文章
边栏推荐
- On the operation mechanism of numpy array
- XSS攻击(笔记)
- Oracle/PLSQL: Rpad Function
- Installing the Damon database using the command line
- Summary of config mechanism and methods in UVM (1)
- Memcached foundations 12
- Oracle/PLSQL: NumToDSInterval Function
- paddlepaddle 19 动态修改模型的最后一层
- Memcached foundation 10
- memcached基础9
猜你喜欢

lottie. JS creative switch button animal head

Why pass SPIF_ Sendchange flag systemparametersinfo will hang?

P5.js death planet

Don't be brainwashed. This is the truth about the wages of 90% of Chinese people

热议:月薪1.8万却毫无意义的工作,你干吗?

达梦数据库安装

谷歌开始卷自己,AI架构Pathways加持,推出200亿生成模型

Google began to roll itself, AI architecture pathways was blessed, and 20billion generation models were launched

three. JS domino JS special effect

three.js多米诺骨牌js特效
随机推荐
DAMA、DCMM等数据管理框架各个能力域的划分是否合理?有内在逻辑吗?
Oracle/PLSQL: NumToYMInterval Function
ConstraintLayout(约束布局)开发指南
Summer planning for the long river
Oracle/PLSQL: From_Tz function
Oracle/PLSQL: Translate Function
Oracle/PLSQL: Soundex Function
SQLite reader plug-in tests SQLite syntax
Uninstallation of Dameng database
three.js多米诺骨牌js特效
svg拖拽装扮Kitty猫
学习DiscoDiffusion的最基础操作
Reading a book in idea is too much!
LeetCode 785:判断二分图
mmdetection 用yolox训练自己的coco数据集
Hot discussion: what are you doing for a meaningless job with a monthly salary of 18000?
Memcached basics 15
Oracle/PLSQL: NumToYMInterval Function
Summary of config mechanism and methods in UVM (1)
Oracle/PLSQL: Trim Function