redis(3)-哨兵模式-sentinel
反客为主自动版:后台监控master是否故障,自动在slave中选一个成为master。
实现步骤:
#1.创建文件:/myredisconfig/sentinel.conf
sentinel.conf
#2.内容 被监控数据库名字 host6379 1表示主机挂掉后 ,得票数为多少后成为主机
sentinel monitor host6379 127.0.0.1 6379 1
#3.启动哨兵
cd /usr/local/bin
redis-sentinel myredisconfig/sentinel.conf
#79回来了查看信息
cd /usr/local/bin/myredisconfig
cp redis.conf redis6379.conf
redis-cli -p 6379
info replication
| 79 | 80 | 81 | |
|---|---|---|---|
| 1.79 down了,80 81自动形成小的主从备份模式sentinel 会 switch 到81或者80 | shutdown exit | master | |
| 2.79回来了,成为slave,81成为master,79 80 为slave | 直接成为slave了 | slave | master |

浙公网安备 33010602011771号