【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
相关推荐
东方芷兰2 小时前
伯克利 CS61A 课堂笔记 11 —— Mutability
笔记·python
知初~3 小时前
出行项目案例
hive·hadoop·redis·sql·mysql·spark·database
weixin_425878236 小时前
Redis复制性能优化利器:深入解析replica-lazy-flush参数
数据库·redis·性能优化
左灯右行的爱情6 小时前
Redis数据结构总结-listPack
数据结构·数据库·redis
快下雨了L7 小时前
C++面试笔记(持续更新...)
笔记
想要打 Acm 的小周同学呀7 小时前
Redis三剑客解决方案
数据库·redis·缓存
rkmhr_sef7 小时前
Redis 下载与安装 教程 windows版
数据库·windows·redis
陈无左耳、8 小时前
HarmonyOS学习第3天: 环境搭建开启鸿蒙开发新世界
学习·华为·harmonyos
柃歌8 小时前
【UCB CS 61B SP24】Lecture 7 - Lists 4: Arrays and Lists学习笔记
java·数据结构·笔记·学习·算法
JANGHIGH8 小时前
c++ std::list使用笔记
c++·笔记·list