Redis哨兵机制sentinel集群配置
一、安装redis 1主2从集群
https://www.cnblogs.com/velloLei/p/18422729
二、复制sentinel.conf文件到指定目录
cd /usr/local/redis/data/
cp sentinel.conf ./config/sentinel-26379.conf
修改sentinel.conf,26379、26380、26381的配置文件内容相似
vi sentinel-26379.conf
配置文件内容如下
26379
port 26379
daemonize yes
pidfile "/usr/local/redis/data/sentinel-26379.pid"
logfile "/usr/local/redis/data/redis-sentinel-26379.log"
dir "/usr/local/redis/data/"
sentinel monitor mymaster 127.0.0.1 6879 2 # 当2台Sentinel服务都认为redis服务不可用时,选择新的主节点
三、再配置2台 sentinel
26380 、 26381
sed -i 's/26379/26380/g' sentinel-26380.conf
sed -i 's/26380/26381/g' sentinel-26381.conf
四、启动sentinel哨兵
./redis-sentinel ../conf/sentinel-26379.conf
./redis-sentinel ../conf/sentinel-26380.conf
./redis-sentinel ../conf/sentinel-26381.conf
五、查看日志
模拟宕机
master切换为6881
启动6379
./redis-server sentinel/conf/6879.conf
查看集群角色:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)