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
查看集群角色:

posted @   vello  阅读(115)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
点击右上角即可分享
微信分享提示