zoukankan      html  css  js  c++  java
  • Redis-6.2.1 主从和哨兵模式配置

    Redis主从 + 哨兵模式

    Redis-6.2.1 主从和哨兵模式配置

    Centos 7.4
    master:192.168.80.130
    salve0:192.168.80.131
    slave1:192.168.80.161

    公共操作部分:
    wget https://download.redis.io/releases/redis-6.2.1.tar.gz

    yum install -y gcc gcc-c++

    tar xf redis-6.2.1.tar.gz
    mv redis-6.2.1 /home/redis
    cd /home/redis
    make
    cd src
    make install

    cd ..
    mkdir etc
    mkdir bin
    cp redis.conf etc
    cp mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server redis-sentinel  ../bin/

    iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
    iptables -I INPUT -p tcp --dport 26379 -j ACCEPT
    /etc/init.d/iptables save

    配置master redis.conf
    原有配置基础上修改以下内容:

    bind 0.0.0.0
    port 6379
    protected-mode no
    daemonize yes
    logfile "./redis.log "
    requirepass "pwdtest@163.com"
    masterauth "pwdtest@163.com "

    配置 slave主机的redis.conf
    原有配置基础上修改以下内容:
    bind 0.0.0.0
    port 6379
    protected-mode no
    daemonize yes
    logfile "./redis.log "
    requirepass "pwdtest@163.com"
    masterauth "pwdtest@163.com "
    replicaof 192.168.80.130 6379

    启动3台主机的redis服务
    cd bin/
    ./redis-server /home/redis/etc/redis.conf

    验证:master主机创建值 其他主机能够同步得到
    master:
    redis-cli -p 6379 -a pwdtest@163.com
    set name hhhhahaha
    get name

    set name01 jjjyyy
    get name01

    slave:
    redis-cli -p 6379 -a pwdtest@163.com
    get name
    getname01


    哨兵模式:
    部署三个哨兵,每台服务器一个哨兵,配置方式相同,如下
    cd /home/redis
    cp sentinel.conf etc/
    vi sentinel.conf 原有配置不变 修改以下内容:

    port 26379
    protected-mode no
    daemonize yes
    logfile ./sentinel.log
    sentinel monitor mymaster 192.168.80.130 6379 2
    sentinel auth-pass mymaster pwdtest@163.com
    sentinel down-after-milliseconds mymaster 300
    snetinel parallel-syncs mymaster 1
    sentinel failover-timeout mymaster 180000

    启动3台机器的哨兵:
    cd /home/redis/bin
    redis-sentinel /home/redis/etc/sentinel.conf

    redis-cli -p 26379
    info sentinel

    验证:
    关闭master主机的redis服务
    redis-cli -p 6379 -a pwdtest@163.com
    >shutdown
    >quit

    到其他机器登录查看验证:
    redis-cli -p 6379 -a pwdtest@163.com
    >info replication

    查看日志:
    tail -f sentinel.log
    tail -f redis.log

    ============================================================================================
    End

  • 相关阅读:
    Python元组、列表、字典
    测试通过Word直接发布博文
    Python环境搭建(windows)
    hdu 4003 Find Metal Mineral 树形DP
    poj 1986 Distance Queries LCA
    poj 1470 Closest Common Ancestors LCA
    poj 1330 Nearest Common Ancestors LCA
    hdu 3046 Pleasant sheep and big big wolf 最小割
    poj 3281 Dining 最大流
    zoj 2760 How Many Shortest Path 最大流
  • 原文地址:https://www.cnblogs.com/walkersss/p/14543279.html
Copyright © 2011-2022 走看看