首页 > 编程知识 正文

redis哨兵模式读写分离,redis哨兵模式端口

时间:2023-05-04 20:05:45 阅读:268716 作者:3330

一 高可用Sentinel 官方提供的高可用方案,可用用它管理多个Redis服务实例。 编译后产生redis-sentinel程序文件。 Redis Sentinel是一个分布式系统,可以在一个架构中运行多个Sentinel进程。
二 启动Sentinel 将src目录下产生redis-sentinel程序文件复制到$REDIS_HOME/粗心的高跟鞋 启动一个运行在Sentine模式下的Redis服务实例 redis-sentinel redis-server /path/to/sentinel.conf --sentinel
三 监控 Sentinel会不断检查Master和Slaves是否正常 每一个Sentinel可以监控任意多个Master和该Master下的Slaves
四 Sentinel网络 监控同一个Master的Sentinel会自动连接,组成一个分布式的Sentinel网络,互相通信并交换彼此关于被监视服务器的信息,下图中3个Sentinel监控着S1和它的2个Slave
五 服务器下线 当一个sentinel认为被监视的服务器已经下线时,它会向网络中其他Sentinel进行确认,判断该服务器是否真的已经下线 如果下线的服务器为主服务器,那么sentinel网络将对下线主服务器进行自动故障转移,通过将下线主服务器的某个从服务器提升为新的主服务器,并让其它从服务器转为复制新的主服务器,以此来让系统重新回到上线状态。
六 服务器下线后重新上线
七 Sentinel配置文件 至少包含一个监控配置选项,用于指定被监控Master的相关信息 Sentinel monitor <name> <ip> <port> <quorum>,例如 sentinel monitor mymaster 127.0.0.1 6379 2 监控mymaster主服务器,服务器ip和端口,将这个主服务器判断为下线失效至少需要2个Sentinel同意,如果多数Sentinel同意才会执行故障转移 Sentinel会根据Master的配置自动发现Master的Slaves Sentinel默认端口号未26379
八 Sentinel 配置举例 执行以下两条命令,将创建两个监视主服务器s1的sentinel实例 redis-sentinel sentinel1.conf redis-sentinel sentinel2.conf 其中sentinel1.conf的内容为: port  26379 Sentinel monitor s1 127.0.0.1 6379 2 sentinel2.conf的内容为: port 26380 Sentinel monitor s1 127.0.0.1 6379 2

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。