- 对主从服务器进行监控,redis2.6之后提供了“哨兵”机制。
- 监控Redis系统的运行状况,两点功能:
- 监控主数据库和从数据库是否运行正常。
- 主数据库出现故障时,可以自动将从数据库转换为主数据库,实现自动切换。。
- copy文件sentinel.conf到/usr/local/redis/etc中
- 修改sentinel.conf文件:
- sentinel monitor mymaster 192.168.1.174 6379 1 # 名称、ip、端口、投票选举次数
- sentinel down-after-milliseconds mymaster 5000 # 默认一秒检测一次,这里设置超时5000毫秒为宕机
- sentinel failover-timeout mymaster 900000
- sentinel can-failover mymaster yes
- sentinel parallel-syncs mymaster 2
- 启动sentinel哨兵
- /usr/local/redis/bin/redis-server /usr/local/redis/etc/sentinel.conf —sentinel &
- 查看哨兵相关信息命令
- /usr/local/redis/bin/redis-cli -h 192.168.1.175 -p 26379 info Sentinel
- 关闭主服务器查看集群信息
- /usr/local/redis/bin/redis-cli -h 192.168.1.175 -p 6379 shutdown
Redis配置哨兵
最新推荐文章于 2024-09-19 21:52:00 发布