【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
相关推荐
Brookty7 分钟前
【MySQL】JDBC编程
java·数据库·后端·学习·mysql·jdbc
UQI-LIUWJ13 分钟前
计算机组成笔记:缓存替换算法
笔记·缓存
DKPT21 分钟前
Java设计模式之结构型模式(外观模式)介绍与说明
java·开发语言·笔记·学习·设计模式
编程小白gogogo43 分钟前
Spring学习笔记
笔记·学习·spring
qq_527887871 小时前
【学习笔记】Python中主函数调用的方式
笔记·学习
二闹1 小时前
第十六章:监理基础知识(16.1监理的意义和作用--16.5监理要素)
笔记·产品经理
Chef_Chen1 小时前
从0开始学习R语言--Day37--CMH检验
学习
致***锌2 小时前
etf期权和个股期权哪个期权费更贵?
笔记
软件2053 小时前
【redis使用场景——缓存——数据淘汰策略】
数据库·redis·缓存
hjs_deeplearning3 小时前
认知篇#10:何为分布式与多智能体?二者联系?
人工智能·分布式·深度学习·学习·agent·智能体