• centos7的redis加哨兵系统


    三台服务器

    1、下载

    wget http://download.redis.io/releases/redis-5.0.3.tar.gz
    tar -zxvf redis-5.0.3.tar.gz
    cd redis-5.0.3
    make
    make test //检查一下 看有没有问题
    make install

    2、安装

    会在src目录下生成几个可执行文件,分别是mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server。其中redis-server是启动Redis服务的,redis-cli是进入Redis客户端的。

    mkdir etc
    mkdir bin
    mv redis.conf etc/
    mv sentinel.conf etc/
    cd src
    mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-sentinel redis-server redis-trib.rb redis-cli ../bin
    cd ../
    mkdir /usr/local/redis/
    cp -R ./bin /usr/local/redis/
    cp -R ./etc /usr/local/redis/

    mkdir /usr/local/redis/sentinel
    mkdir /usr/local/redis/sentinel/log


    主配置文件:
    # cat /usr/local/redis/etc/redis.conf
    port 7001
    pidfile /usr/local/redis/redis_7001.pid
    # slaveof 10.10.21.197 7001
    logfile "/usr/local/redis/redis_7001.log"
    # requirepass 123456
    daemonize yes
    bind 0.0.0.0
    # masterauth 123456

    从配置文件:
    # cat /usr/local/redis/etc/redis.conf
    port 7001
    pidfile /usr/local/redis/redis_7001.pid
    # slaveof 10.10.21.197 7001
    logfile "/usr/local/redis/redis_7001.log"
    # requirepass 123456
    daemonize yes
    bind 0.0.0.0
    # masterauth 123456

    从配置文件:
    # cat /usr/local/redis/etc/redis.conf
    port 7001
    pidfile /usr/local/redis/redis_7001.pid
    slaveof 10.10.21.197 7001
    logfile "/usr/local/redis/redis_7001.log"
    # requirepass 123456
    daemonize yes
    bind 0.0.0.0
    # masterauth 123456

    sentinel(哨兵配置文件,三台)
    # cat /usr/local/redis/etc/sentinel.conf
    port 26379
    daemonize yes
    protected-mode no
    dir "/usr/local/redis/sentinel"
    pidfile "/usr/local/redis/sentinel/log/redis-sentinel.pid"
    logfile "/usr/local/redis/sentinel/log/redis-sentinel.log"
    sentinel monitor redis_master 10.10.21.197 7001 2
    sentinel down-after-milliseconds redis_master 9000
    sentinel failover-timeout redis_master 9000


    启动
    # cd /usr/local/redis
    # ./bin/redis-server ./etc/redis.conf

    检查
    # ./bin/redis-cli -p 7001
    127.0.0.1:7001> info
    # Replication
    role:master
    connected_slaves:2
    slave0:ip=10.10.21.198,port=7001,state=online,offset=7041,lag=1
    slave1:ip=10.10.21.199,port=7001,state=online,offset=7184,lag=0
    master_replid:9bec683a0d3d92a34346d2e5a7c38e6fc0c5d90d
    master_replid2:0000000000000000000000000000000000000000
    master_repl_offset:7184
    second_repl_offset:-1
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:1
    repl_backlog_histlen:7184


    哨兵启动
    # cd /usr/local/redis
    # ./bin/redis-sentinel ./etc/sentinel.conf

    检查
    # redis-cli -p 26379
    127.0.0.1:26379> info
    # Sentinel
    sentinel_masters:1
    sentinel_tilt:0
    sentinel_running_scripts:0
    sentinel_scripts_queue_length:0
    sentinel_simulate_failure_flags:0
    master0:name=redis_master,status=ok,address=10.10.21.197:7001,slaves=2,sentinels=3

    haproxy的redis哨兵负载
    frontend redis8001
    bind *:8001
    default_backend redis_8001_backend
    backend redis_8001_backend
    option tcp-check
    tcp-check connect
    # tcp-check send AUTH admin
    # tcp-check expect string +OK
    tcp-check expect string +PONG
    tcp-check send INFO REPLICATION
    tcp-check expect string role:master
    tcp-check send INFO REPLICATION
    tcp-check expect rstring connected_slaves:[1-9]
    tcp-check send QUIT
    tcp-check expect string +OK
    server redis1_7001 10.10.21.197:7001 check inter 1s
    server redis2_7001 10.10.21.198:7001 check inter 1s
    server redis3_7001 10.10.21.199:7001 check inter 1s

  • 相关阅读:
    *Reverse Linked List II
    *Insertion Sort List
    Convert Sorted List to Binary Search Tree
    Reverse Integer
    read cache return null
    纳秒和随机数
    libthread_db
    gdb
    tls session resumption
    http://www.linux-commands-examples.com/xmllint
  • 原文地址:https://www.cnblogs.com/wangshuyang/p/11758146.html
Copyright © 2020-2023  润新知