【redis学习笔记】哨兵节点编排

编写 docker-compose.yml

创建 /root/redis-sentinel/docker-compose.yml , 同时 cd 到 yml 所在⽬录中;
注意: 每个⽬录中只能存在⼀个 docker-compose.yml ⽂件.

bash 复制代码
version: '3.7'
services:
 sentinel1:
 image: 'redis:5.0.9'
 container_name: redis-sentinel-1
 restart: always
 command: redis-sentinel /etc/redis/sentinel.conf
 volumes:
 - ./sentinel1.conf:/etc/redis/sentinel.conf
 ports:
 - 26379:26379
 sentinel2:
 image: 'redis:5.0.9'
 container_name: redis-sentinel-2
 restart: always
 command: redis-sentinel /etc/redis/sentinel.conf
 volumes:
 - ./sentinel2.conf:/etc/redis/sentinel.conf
 ports:
 - 26380:26379
 sentinel3:
 image: 'redis:5.0.9'
 container_name: redis-sentinel-3
 restart: always
 command: redis-sentinel /etc/redis/sentinel.conf
 volumes:
 - ./sentinel3.conf:/etc/redis/sentinel.conf
 ports:
 - 26381:26379

创建配置⽂件

创建 sentinel1.conf sentinel2.conf sentinel3.conf 三份⽂件的内容是完全相同的;都放到 /root/redis-sentinel/ ⽬录中.

bash 复制代码
bind 0.0.0.0
port 26379
sentinel monitor redis-master redis-master 6379 2
sentinel down-after-milliseconds redis-master 1000

启动所有容器

bash 复制代码
docker-compose up -d

查看运⾏⽇志

bash 复制代码
docker-compose logs

观察 redis-sentinel 的配置 rewrite

再次打开哨兵的配置⽂件, 发现⽂件内容已经被⾃动修改了

bash 复制代码
bind 0.0.0.0
port 26379
sentinel myid 4d2d562860b4cdd478e56494a01e5c787246b6aa
sentinel deny-scripts-reconfig yes
# Generated by CONFIG REWRITE
dir "/data"
sentinel monitor redis-master 172.22.0.4 6379 2
sentinel down-after-milliseconds redis-master 1000
sentinel config-epoch redis-master 1
sentinel leader-epoch redis-master 1
sentinel known-replica redis-master 172.22.0.2 6379
sentinel known-replica redis-master 172.22.0.3 6379
sentinel known-sentinel redis-master 172.22.0.7 26379 f718caed536d178f5ea6d1316d
sentinel known-sentinel redis-master 172.22.0.5 26379 2ab6de82279bb77f8397c309d3
sentinel current-epoch 1
相关推荐
淮北4945 小时前
vim学习进阶
学习·编辑器·vim
智者知已应修善业6 小时前
【proteus中lm339电压滞回比较器达到三角波转换成方波】2023-4-13
驱动开发·经验分享·笔记·硬件架构·proteus·硬件工程
551只玄猫6 小时前
新编大学德语1第三版笔记 第5课Essen und Trinken
笔记·学习笔记·德语·外语·德语a1·自学德语·新编大学德语
sayang_shao6 小时前
ARM架构运行模式学习笔记
arm开发·学习·架构
不只会拍照的程序猿7 小时前
《嵌入式AI筑基笔记02:Python数据类型01,从C的“硬核”到Python的“包容”》
人工智能·笔记·python
happymaker06268 小时前
web前端学习日记——DAY04
前端·学习
lay_liu9 小时前
Linux安装redis
linux·运维·redis
solicitous9 小时前
遇到一个口头机遇
学习·生活
lay_liu11 小时前
ubuntu 安装 Redis
linux·redis·ubuntu
观书喜夜长11 小时前
大模型应用开发学习-基于 LangChain 框架实现的交互式问答脚本
python·学习