• redis哨兵常用命令和监控


    sentinel monitor mymaster2 192.168.100.5 28001 2
    sentinel set mymaster2 client-reconfig-script /etc/redis/reconfig.sh
    sentinel flushconfig

    role命令
    查看sentinel monitor的master names名字

    sentinel masters
    查看所有监控master及其配置信息

    sentinel master monitor_name
    查看指定监控master及其配置信息


    sentinel failover monitor_name
    手动进行swithover切换主从,如果有多个slave会选择哪个slave做为新的master,待测试?

    sentinel moniotr <name> <ip> <port> <quorum>
    添加监视的master

    sentinel remove monitor_name
    将监视的为name的master移除监视


    sentinel set <mastername> [<option> <value>]
    修改监视的master的一些属性
    down-after-milliseconds 过了这个时间考虑master go down
    failover-timeout 刷新故障转移状态的最大时间
    parallel-syncs slave同时reconfigure的个数
    notification-script 设置通知脚本
    client-reconfig-script 设置通知脚本
    auth-pass 执行auth的密码
    quorum 修改master的quorum


    sentinel flushconfig
    将sentinel信息写入到配置文件中

    sentinel配置文件示例:

    说明:

    sentinel启动后需要手动将配置文件对应的调整为sentinel deny-scripts-reconfig no,否则不支持命令行runtime修改client-reconfig-script
    # SECURITY
    #
    # By default SENTINEL SET will not be able to change the notification-script
    # and client-reconfig-script at runtime. This avoids a trivial security issue
    # where clients can set the script to anything and trigger a failover in order
    # to get the program executed.

    #sentinel deny-scripts-reconfig yes

    daemonize yes
    pidfile "/home/redis/sentinel/25000/redis.pid"
    loglevel notice
    protected-mode yes
    bind 192.168.100.5
    logfile "/home/redis/sentinel/25000/redis.log"
    port 25000
    dir "/home/redis/sentinel/25000"
    # Generated by CONFIG REWRITE
    sentinel myid 0338c4ceb7cf39a8037a22fa17d0f7a76923b5a0
    sentinel deny-scripts-reconfig no
    sentinel monitor mymaster2 192.168.100.5 28001 2
    sentinel client-reconfig-script mymaster2 /etc/redis/reconfig.sh
    sentinel config-epoch mymaster2 4
    sentinel leader-epoch mymaster2 4
    sentinel known-replica mymaster2 192.168.100.6 28001
    sentinel known-sentinel mymaster2 192.168.100.7 25000 06f937e1d35496dc66d2899e3b25e286ff91d658
    sentinel known-sentinel mymaster2 192.168.100.6 25000 ede86ac0b7d2ff7b532d0e5352ba6e33dd36670e
    
    sentinel monitor mymaster1 192.168.100.6 28002 2
    sentinel client-reconfig-script mymaster1 /etc/redis/reconfig.sh
    sentinel config-epoch mymaster1 5
    sentinel leader-epoch mymaster1 1
    sentinel known-replica mymaster1 192.168.100.5 28002
    sentinel known-sentinel mymaster1 192.168.100.7 25000 06f937e1d35496dc66d2899e3b25e286ff91d658
    sentinel known-sentinel mymaster1 192.168.100.6 25000 ede86ac0b7d2ff7b532d0e5352ba6e33dd36670e
    sentinel current-epoch 5
    

      

    sentinel client-reconfig-script脚本示例

    #!/bin/bash
    
    check_time=$(date +"%F-%T")
    master_name="$1"
    from_ip="$4"
    from_port="$5"
    to_ip="$6"
    to_port="$7"
    
    
    #填写自己正确的机器人链接
    curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxx' 
       -H 'Content-Type: application/json' 
       -d '
       {
            "msgtype": "text",
            "text": {
                "content": "【'$check_time' '$master_name' redis failover】
    from
    '$from_ip:$from_port'
    to
    '$to_ip:$to_port'",
           	    "mentioned_list":["xiaodongl"]
            }
       }'
    

    redis主从切换告警

    欢迎多交流(QQ:616793474/329003748),谢谢!
  • 相关阅读:
    wxpython 支持python语法高亮的自定义文本框控件的代码
    小米平板6.0以上系统如何不用Root激活Xposed框架的步骤
    vivo4.0系统怎么不ROOT激活Xposed框架的教程
    oppo设备怎么样无需root激活XPOSED框架的教程
    OPPO A7x在哪里开启usb调试模式的详细经验
    python将两个数组合并成一个数组的两种方法的代码
    (最详细)小米MIX的Usb调试模式在哪里打开的教程
    (简单)华为荣耀9i LLD-AL20的Usb调试模式在哪里开启的方法
    linux c ---raise 使用范例的代码
    oppo8.0系统怎么无需Root激活Xposed框架的经验
  • 原文地址:https://www.cnblogs.com/imdba/p/14814088.html
Copyright © 2020-2023  润新知