zoukankan      html  css  js  c++  java
  • 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,表示替换成功

  • 相关阅读:
    S2-052 RCE漏洞 初步分析
    Struts S2-048 RCE漏洞分析
    CSP-S2019游记
    委托学习笔记1:委托的基本使用
    jQuery无刷新上传学习心得
    Nuget-自定义模板的创建与使用
    DotNetCore笔记-nginx代理访问swagger
    SQLServer中Partition By 函数的使用
    IE11 Windows7下F12 DOC资源管理器不能用Exception in window.onload: Error: An error has ocurredJSPlugin.3005
    Angular-ui-router入门
  • 原文地址:https://www.cnblogs.com/guarderming/p/10328882.html
Copyright © 2011-2022 走看看