原来连接:深刻学习Redis(4):哨兵html
哨兵的功能:redis
典型的哨兵架构图以下所示:架构
它由两部分组成,哨兵节点和数据节点:ide
哨兵系统:包含1个主节点、2个从节点和3个哨兵节点学习
主从节点配置:spa
主节点: port 6379 daemonize yes logfile "6379.log" dbfilename "dump-6379.rdb" 从节点1: port 6380 daemonize yes logfile "6380.log" dbfilename "dump-6380.rdb" slaveof 192.168.92.128 6379 从节点2: port 6381 daemonize yes logfile "6381.log" dbfilename "dump-6381.rdb" slaveof 192.168.92.128 6379
启动主从节点命令相同:code
redis-server redis-6379.conf redis-server redis-6380.conf redis-server redis-6381.conf
哨兵节点配置:server
port 26379 daemonize yes logfile "26379.log" sentinel monitor mymaster 192.168.92.128 6379 2
其中,sentinel monitor mymaster 192.168.92.128 6379 2 配置的含义是:该哨兵节点监控192.168.92.128:6379这个主节点,该主节点的名称是mymaster,最后的2的含义与主节点的故障断定有关:至少须要2个哨兵节点赞成,才能断定主节点故障并进行故障转移。htm
启动哨兵节点两种方式:blog
redis-sentinel sentinel-26379.conf redis-server sentinel-26379.conf --sentinel
哨兵系统的搭建过程,有几点须要注意: