【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
相关推荐
暴富奥利奥36 分钟前
完成docker方式的ros环境配置
linux·学习·docker·容器
总有刁民想爱朕ha1 小时前
AI大模型学习(17)python-flask AI大模型和图片处理工具的从一张图到多平台适配的简单方法
人工智能·python·学习·电商图片处理
zhengzizhe1 小时前
Redssion出现attempt to unlock lock, not locked by current thread by node id
redis
Cathy Bryant1 小时前
球极平面投影
经验分享·笔记·数学建模
Larry_Yanan2 小时前
QML学习笔记(三十一)QML的Flow定位器
java·前端·javascript·笔记·qt·学习·ui
与己斗其乐无穷2 小时前
C++学习记录(17)红黑树简单实现map和set
学习
杰瑞学AI2 小时前
我的全栈学习之旅:FastAPI (持续更新!!!)
后端·python·websocket·学习·http·restful·fastapi
The_Killer.2 小时前
近世代数(抽象代数)详细笔记--环(也有域的相关内容)
笔记·学习·抽象代数·
Larry_Yanan3 小时前
QML学习笔记(三十)QML的布局器(Layouts)
c++·笔记·qt·学习·ui
不会kao代码的小王3 小时前
突破机房围墙:openEuler设备的公网管理实战指南
开发语言·数据库·笔记