文件结构

1. redis-sentinel

 1-1.  docker-compose.yml

1-2. sentinel

   1-2-1 docker-compose.yml

  1-2-2 sentinel.conf

  1-2-3 sentinel1.conf

  1-2-4 sentinel2.conf

  1-2-5 sentinel3.conf

1、docker-compose 文件实现一主两从

编写docker-compose.yml文件,内容如下:

version: '3.7'
services:
master:
image: redis
container_name: redis-master
restart: always
command: redis-server --requirepass GaosiDev --masterauth GaosiDev
ports:
- 6380:6379 slave1:
image: redis
container_name: redis-slave-1
restart: always
command: redis-server --slaveof redis-master 6379 --requirepass GaosiDev --masterauth GaosiDev
ports:
- 6381:6379 slave2:
image: redis
container_name: redis-slave-2
restart: always
command: redis-server --slaveof redis-master 6379 --requirepass GaosiDev --masterauth GaosiDev
ports:
- 6382:6379

docker-compose 文件实现 sentinel

version: '2'
services:
sentinel1:
image: redis ## 镜像
container_name: redis-sentinel-1
ports:
- "26379:26379"
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
volumes:
- "./sentinel1.conf:/usr/local/etc/redis/sentinel.conf"
sentinel2:
image: redis ## 镜像
container_name: redis-sentinel-2
ports:
- "26380:26379"
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
volumes:
- "./sentinel2.conf:/usr/local/etc/redis/sentinel.conf"
sentinel3:
image: redis ## 镜像
container_name: redis-sentinel-3
ports:
- "26381:26379"
command: redis-sentinel /usr/local/etc/redis/sentinel.conf
volumes:
- ./sentinel3.conf:/usr/local/etc/redis/sentinel.conf
networks:
default:
external:
name: redis-sentinel_default ##通过(docker inspect 主节点容器id)来查看,对应 NetworkMode

编辑 sentinel.conf 文件

port 26379
dir /tmp
#172.18.0.3填写自己的主节点ip,通过(docker inspect 主节点容器id)来查看,对应 IPAddress
sentinel monitor mymaster 172.17.0.4 6379 2
sentinel auth-pass mymaster GaosiDev
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 10000
sentinel deny-scripts-reconfig yes

参考链接

https://www.cnblogs.com/ruiyeclub/p/12355073.html

https://www.cnblogs.com/JulianHuang/p/12650721.html

最新文章

  1. XML和JSON数据格式对比
  2. Oracle GoldenGate 12c (12.1.2.0.1) for IBM DB2 iSeries
  3. php文本操作方法集合比较
  4. hadoop2.6.0汇总:新增功能最新编译 32位、64位安装、源码包、API下载及部署文档
  5. yii中的自定义组件
  6. 【转】【opencv】仿射变换
  7. 对于方法 String.Contains,只支持可在客户端上求值的参数。
  8. iOS推送证书p12转成pem
  9. Spring+SpringMVC+MyBatis+easyUI整合基础篇(六)maven整合SSM
  10. 面向对象编程思想(前传)--你必须知道的javascript
  11. 移动开发必须要弄明白的问题】详解Eclipse转Android Studio
  12. 为什么用CDN给你网站加速?
  13. Scala - 快速学习04 - 求值策略
  14. java学习笔记37(sql工具类:JDBCUtils)
  15. ubuntu6.4系统安装JIRA-7.8
  16. Zookeeper中Session Timeout的那些事
  17. 2. Python3输入与输出
  18. js 字符中 带 函数 再传对象参数
  19. echarts一些笔记
  20. OpenStack入门篇(一)之云计算的概念

热门文章

  1. IT菜鸟之思科模拟实验(PT)
  2. Linux服务之Apache服务篇
  3. 治理对象ing
  4. Go语言网络通信---string与int互转,int64与[]byte互转,int直接互转,string与[]byte互转
  5. CUDA上的量化深度学习模型的自动化优化
  6. Linux 2 的 Windows 子系统上发布 CUDA
  7. 使用Keil语言的嵌入式C编程教程(下)
  8. 痞子衡嵌入式:嵌入式里串口(UART)自动波特率识别程序设计与实现
  9. PyQt5开发实践(一、准备篇)
  10. (5)使用自定Web根目录