• redis5.0配置一主两从三哨兵


    基础配置

    systemctl stop firewalld && systemctl disable firewalld
    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
    
    vi /etc/hosts
    ip1 node1
    ip2 node2
    ip3 node3
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    redis

    配置一主两从

    yum -y install autoconf automake bison byacc cscope ctags diffstat doxygen elfutils flex gcc-gfortran git indent intltool libtool patch patchutils rcs redhat-rpm-config rpm-build rpm-sign subversion swig systemtap
    
    tar -xf redis-5.0.8.tar.gz
    cd redis-5.0.8
    make MALLOC=libc && make install
    
    #节点1
    vi redis.conf
    #redis只接受来自绑定网络接口的请求
    bind ip1
    #开启守护进程模式,在该模式下redis会在后台运行,并将进程pid号写入至pidfile指定的文件中,此时将一直运行,除非手动kill该进程
    daemonize yes
    #从实例连接主实例的密码
    masterauth 1qaz2!QAZ@
    #客户端连接redis的密码
    requirepass 1qaz2!QAZ@
    
    #节点2
    vi redis.conf
    bind ip2
    daemonize yes
    replicaof ip1 6379
    masterauth 1qaz2!QAZ@
    
    
    #节点3
    vi redis.conf
    bind ip3
    daemonize yes
    replicaof ip1 6379
    masterauth 1qaz2!QAZ@
    
    #启动
    redis-server redis.conf 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34

    开启哨兵模式

    #节点1
    #未使用 bind 指令明确配置一组IP地址、未配置密码时,客户端(非服务器本机)可以正常连接
    protected-mode no
    daemonize yes
    #正常启动后生成
    sentinel myid 6b190ab6b2b8198c53a0ae9026143f46cdaac2a8
    #2个从节点判定失败后切换
    sentinel monitor mymaster ip1 6379 2
    sentinel auth-pass mymaster 1qaz2!QAZ@
    
    #节点2
    protected-mode yes
    daemonize yes
    sentinel myid 42ef52d7a37bd4827ccf24a85be29514cb40bfca
    sentinel monitor mymaster ip1 6379 2
    sentinel auth-pass mymaster 1qaz2!QAZ@
    
    #节点3
    protected-mode yes
    daemonize yes
    sentinel myid 4a4df01ffaa7b08950220d372d5785645d5239549
    sentinel monitor mymaster ip1 6379 2
    sentinel auth-pass mymaster 1qaz2!QAZ@
    
    redis-sentinel sentinel.conf
    
    ps -ef | grep redis
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    在这里插入图片描述

    控制台

    #登录
    redis-cli -h host -p port
    #查看状态
    info
    #指定主库
    slaveof host post
    #一般操作
    get key
    set key value
    del key
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
  • 相关阅读:
    二、代码块的加载顺序
    SG-Former:具有进化Token重新分配的自引导Transformer
    美团即时零售的优势不止“快”
    MySQL 分组排序后 → 如何取前N条或倒数N条
    Rules1:模板类型推导
    如何在IDEA 中设置背景图片
    bwapp下载安装
    功能测试进阶自动化测试?这9个必备自动化技能看看你有没有掌握...
    设计模式(一)----设计模式概述及UML图解析
    String长度限制?
  • 原文地址:https://blog.csdn.net/hy19930118/article/details/133457283