zoukankan      html  css  js  c++  java
  • Redis一主二从Sentinel监控配置

    本文基于Redis单实例安装安装。
    https://gper.club/articles/7e7e7f7ff7g5egc4g6b

    开启哨兵模式,至少需要3个Sentinel实例(奇数个,否则无法选举Leader)。
    本例通过3个Sentinel实例监控3个Redis服务(1主2从)。

    IP地址	          节点角色&端口
    192.168.8.203	Master:6379 / Sentinel : 26379
    192.168.8.204	Slave :6379 / Sentinel : 26379
    192.168.8.205	Slave :6379 / Sentinel : 26379
    

    网络结构图:

    在204和205的redis.conf配置中添加一行

    slaveof 192.168.8.203 6379
    

    在203、204、205创建sentinel配置文件(单例安装后根目录下默认有sentinel.conf,可以先备份默认的配置)

    cd /usr/local/soft/redis-5.0.5
    mkdir logs
    mkdir rdbs
    mkdir sentinel-tmp
    vim sentinel.conf
    

    sentinle.conf配置文件内容,三台机器相同

    daemonize yes
    port 26379
    protected-mode no
    dir "/usr/local/soft/redis-5.0.5/sentinel-tmp"
    sentinel monitor redis-master 192.168.8.203 6379 2
    sentinel down-after-milliseconds redis-master 30000
    sentinel failover-timeout redis-master 180000
    sentinel parallel-syncs redis-master 1
    
    

    在3台机器上分别启动Redis和Sentinel

    cd /usr/local/soft/redis-5.0.5/src
    ./redis-server ../redis.conf
    ./redis-sentinel ../sentinel.conf
    

    在3台机器上查看集群状态:

    redis> info replication
    

    2.png

    模拟master宕机,在203执行:

    redis> shutdown
    

    注意看sentinel.conf里面的redis-master被修改了,变成了当前master的IP端口。

    redis> info replication
    

    这个时候会有一个slave节点被Sentinel设置为master。
    再次启动master,它不一定会被选举为master。

    slave宕机和恢复测试省略。

    转载出处:https://gper.club/articles/7e7e7f7ff7g5egc7g6a

  • 相关阅读:
    jQuery Validate 插件
    本地存储 web storage
    ajax简介及JS写原生ajax
    swiper插件简介及用法
    JavaScript中的string对象及方法
    javascript数组中的方法
    面向对象
    logging模块具体补充
    模块补充
    内置函数总结
  • 原文地址:https://www.cnblogs.com/Payne-SeediqBale/p/11706480.html
Copyright © 2011-2022 走看看