当前位置:网站首页>Docker部署一个Redis集群
Docker部署一个Redis集群
2022-06-10 13:36:00 【java_prinln】
Docker 部署一个Redis集群
分片 + 高可用 + 负载均衡

创建网卡
docker network create redis --subnet 172.38.0.0/16
通过脚本创建六个redis配置
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 cluster-announce-ip 172.38.0.1${port} cluster-announce-port 6379 cluster-announce-bus-port 16379 appendonly yes EOF
done
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 --ip 172.38.0.1${port} redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf; \
# 启动6个容器
docker run -p 6371:6379 -p 16371:16379 --name redis-1 \
-v /mydata/redis/node-1/data:/data \
-v /mydata/redis/node-1/conf/redis.conf:/etc/redis/redis.conf \
-d --net redis --ip 172.38.0.11 redis:5.0.9-alpine3.11 redis-server
/etc/redis/redis.conf
docker run -p 6376:6379 -p 16376:16379 --name redis-6 \
-v /mydata/redis/node-6/data:/data \
-v /mydata/redis/node-6/conf/redis.conf:/etc/redis/redis.conf \
-d --net redis --ip 172.38.0.16 redis:5.0.9-alpine3.11 redis-server
/etc/redis/redis.conf
进入一个redis,注意这里是 sh命令
docker exec -it redis-1 /bin/sh
创建集群
redis-cli --cluster create 172.38.0.11:6379
172.38.0.12:6379 172.38.0.13:6379 172.38.0.14:6379 172.38.0.15:6379 172.38.0.16:6379 --
cluster-replicas 1
连接集群
redis-cli -c
查看集群信息
cluster info
查看节点
cluster nodes
set a b
停止到存值的容器
然后再次get a,发现依旧可以获取值
查看节点,发现高可用完全没问题
边栏推荐
- The relocation of Apple's production line shows that 5g industrial interconnection and intelligent manufacturing have limited help for manufacturing in China
- Apple邮箱配置QQ邮箱,163邮箱,edu邮箱,gmail邮箱,获取gmail日历
- 传奇登录器提示连接服务器失败是怎么回事?怎么解决?
- Let resources flow freely in the cloud and locally
- apache atlas 快速入门
- CL210OpenStack操作的故障排除--常见核心问题的故障排除
- TextInputLayout使用详解
- 格力手机叫板苹果手机?除了嘴硬之外,恐怕再无其他
- Libre circulation des ressources dans le cloud et localement
- Cardview usage and properties
猜你喜欢

Meetup review how Devops & mlops solve the machine learning dilemma in enterprises?

传奇登录器提示连接服务器失败是怎么回事?怎么解决?

If I write the for loop again, I will hammer myself

In depth analysis of "circle group" relationship system design | series of articles on "circle group" technology

H. 265 introduction to coding principles

Sohu employees encounter wage subsidy fraud. What is the difference between black property and gray property and how to trace the source?

【深度学习05】 交叉熵损失函数
![[FAQ] résumé des problèmes courants et des solutions lors de l'utilisation de l'interface API rest du Service de santé sportive](/img/ff/96a0a77795b271bef3a8ade2d646c3.png)
[FAQ] résumé des problèmes courants et des solutions lors de l'utilisation de l'interface API rest du Service de santé sportive

The shortcomings of the "big model" and the strengths of the "knowledge map"

MMdetection增加评估指标precision
随机推荐
Smart campus security channel and video monitoring solution
Qt: 访问其他窗体中的控件
What are the common automated test frameworks? Shanghai software testing company Amway
基于FPGA的VGA协议实现
[operation tutorial] how to correctly use the Hikvision demo tool to configure the channel to go online?
32、树莓派的简单测试串口通信和超声波模块测距
10 competitive airpods Pro products worth your choice
【深度学习05】 交叉熵损失函数
32. Simple test of raspberry pie serial port communication and ultrasonic module ranging
[FAQ] résumé des problèmes courants et des solutions lors de l'utilisation de l'interface API rest du Service de santé sportive
【C语言】指针函数与函数指针、数组函数
Periodically brush the data in the database and synchronize only the modified fields
buuctf [PHP]CVE-2019-11043
十款好用跨浏览器测试工具分享,好物值得收藏
Libre circulation des ressources dans le cloud et localement
【抬杠C#】如何实现接口的base调用
buuctf [Jupyter]notebook-rce
What does the multi cloud management platform CMP mean? Who can explain it clearly
Notes - simple but adequate series_ The Yapi return parameter data should be an object type problem solving record
解决安装gerapy的时候报错:ERROR: Cannot uninstall ‘certifi‘. It is a distutils installed project...