Redis哨兵机制

在主从架构状态下,如果master节点宕机,则不可以进行写操作,所以需要引入哨兵机制,重新选取master节点,保证Redis主从架构正常运行。

1.在三个节点上分别修改配置文件sentinel.conf

image.png

1.bind: 如果redis暴露在公网,需要配置bind ip
2.修改# protected-mode no 为 protected-mode no
3.修改daemonize no 为 daemonize yes
4.logfile /usr/local/redis/sentinel/redis-sentinel.log
5.dir /usr/local/redis/sentinel/
6.sentinel monitor mymaster 127.0.0.1 6379 2
mymaster为sentinel的昵称
127.0.0.1 为master的ip,需要根据自己的环境进行修改
2 为哨兵的数量
7.修改sentinel auth-pass mymaster ’password‘
8.修改# sentinel down-after-milliseconds <master-name> <milliseconds>
sentinel down-after-milliseconds mymaster 10000
9.sentinel parallel-syncs mymaster 1
10.sentinel failover-timeout mymaster 180000
主备切换时间

2.启动哨兵

src/redis-sentinel sentinel.conf

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容