• redis哨兵配置


    前提是要搭建好redis主从同步:

    Vim /root/redis/sentinel.conf

    主redis:

    port 26379
    daemonize yes
    protected-mode no   #保护模式如果开启只接受回环地址的ipv4和ipv6地址链接,拒绝外部链接,而且正常应该配置多个哨兵,避免一个哨兵出现独裁情况,如果配置多个哨兵那如果开启也会拒绝其他sentinel的连接。导致哨兵配置无法生效。
    logfile "/var/logs/sentinel.log"      #指明日志文件
    dir "/root/redis/"
    sentinel monitor mymaster 192.168.1.190 6379 1   #哨兵监控的master。
    sentinel down-after-milliseconds mymaster 5000     #master或者slave多少时间(默认30秒)不能使用标记为down状态。
    sentinel failover-timeout mymaster 9000    #若哨兵在配置值内未能完成故障转移操作,则任务本次故障转移失败。

    sentinel auth-pass mymaster 123456    #如果redis配置了密码,那这里必须配置认证,否则不能自动切换

    启动服务:

     /data/redis/src/redis-sentinel /data/redis/sentinel.conf   

    注意:

    将主redis上面的sentinel.conf文件复制到两个从redis上面 

    从(1)redis:

    Vim /root/redis/sentinel.conf

    只修改:

    Port 26380

    启动服务:

     /data/redis/src/redis-sentinel /data/redis/sentinel.conf 

    从(2)redis:

    Vim /root/redis/sentinel.conf

    只修改:

    Port 26380

    启动服务:

     /data/redis/src/redis-sentinel /data/redis/sentinel.conf 

    6.2 验证哨兵效果

    主redis上面

    从1:

    ./redis-cli –p 6380

    Auth 123456

    Info

    从2:

    ./redis-cli –p 6381

    Auth 123456

    Info

    然后down掉主redis

    Shutdown

    再从的上面查:

    从的立马成为主redis,表示替换成功

  • 相关阅读:
    dedecms织梦建站总结
    ubuntu安装
    git命令
    关于测试日报
    Appium环境搭建(Windows版)
    jmeter,CSV数据加载、数据库连接、正则
    jmeter,参数、Bean Shell断言
    jmeter安装和组件说明
    造数据
    WEB UI自动化
  • 原文地址:https://www.cnblogs.com/guarderming/p/10328882.html
Copyright © 2020-2023  润新知