zoukankan      html  css  js  c++  java
  • redis配置主从备份以及主备切换方案配置

    前提:redis中,主从切换场景中,没有绝对的主和从,只有初始化的主和从,然后当主down后,从就变成主了,而主即使连接上,也是从,不会变为主

    1、redis-server的主备关系:

    需要配置的机器,以及主备关系如下:

    master:10.118.36.10

    slave1:10.118.36.74

    slave2:10.118.36.161

    2、修改redis-server的配置文件

    切换到redis的根目录

    # cd /home/admin/Downloads/redis-3.0.3

    master配置不变,两台slave修改配置文件(# vi redis-3.0.3/redis.conf),添加如下语句,其余用默认配置: slaveof 10.118.36.10 6379

    3、修改redis-sentinel的配置文件(# vi redis-3.0.3/sentinel.conf),但是这里我使用一个新的文件(# vi redis-3.0.3/sentinel-test.conf):

    切换到redis的根目录

    # cd /home/admin/Downloads/redis-3.0.3
    # vi redis-3.0.3/sentinel-test.conf

    三台机器配置相同,如下:

    ############################代码区域,begin############################
    port 26379
    #MyMaster
    sentinel monitor MyMaster 10.118.36.10 6379 1
    sentinel down-after-milliseconds MyMaster 5000
    sentinel failover-timeout MyMaster 900000
    sentinel parallel-syncs MyMaster 2
    ############################代码区域,end############################

    4、启动redis-server服务和redis-sentinel服务

    切换到redis的根目录

    # cd /home/admin/Downloads/redis-3.0.3

    启动redis-server

    # ./src/redis-server redis.conf

    启动redis-sentinel

    # ./src/redis-sentinelsentinel-test.conf

    5、检查redis状态(三台都执行)

    切换到redis的根目录

    # cd /home/admin/Downloads/redis-3.0.3

    查询命令

    # ./src/redis-cli

    查询状态信息

    > ping
    返回的结果如果是PONG,则表示服务运行正常,然后继续执行命令,检查主备是否正常
    > info Replication
    查看返回结果(关键点)master应为(offset和lag无所谓):
    role:master
    connected_slaves:2
    slave0:ip=10.118.36.74,port=6379,state=online,offset=1241704,lag=0
    slave1:ip=10.118.36.161,port=6379,state=online,offset=1241704,lag=0

    slave应为:

    role:slave
    master_host:10.118.36.10
    master_port:6379
    master_link_status:up

    6、检查sentinel状态(三台都执行)

    切换到redis的根目录

    # cd /home/admin/Downloads/redis-3.0.3

    执行命令

    # ./src/redis-cli -p 26379

    查询状态信息

    > info

    查看结果如果有如下所示,即表示正常集群配置正常运行

    # Sentinel
    sentinel_masters:1
    sentinel_tilt:0
    sentinel_running_scripts:0
    sentinel_scripts_queue_length:0
    master0:name=MyMaster,status=ok,address=10.118.36.10:6379,slaves=2,sentinels=3

    本文转自:http://blog.csdn.net/gsying1474/article/details/48302565

  • 相关阅读:
    missing requires of libmysqlclient.so.18()(64bit)
    Ambari安装HDP问题:User root is not allowed to impersonate anonymous.User: hcat is not allowed to impersonate ambari-qa
    ambari2.6.50 openssl 版本问题:SSLError: Failed to connect. Please check openssl library versions. Openssl error upon host registration
    HDP 2.6 requires libtirpc-devel
    Kafka 如何读取offset topic内容 (__consumer_offsets)
    Linux集群时间同步方法
    centos7 ambari2.6.1.5+hdp2.6.4.0 大数据集群安装部署
    Centos7.3离线(rpm方式)安装mysql服务
    ubuntu安装rpm的方法
    kerberos环境storm配置:Running Apache Storm Securely
  • 原文地址:https://www.cnblogs.com/dreammyle/p/5740645.html
Copyright © 2011-2022 走看看