• 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
  • 相关阅读:
    数据结构与算法——线性查找法
    Java 21 正式 GA,虚拟线程真的来了
    数据好合: Argilla 和 Hugging Face Spaces 携手赋能社区合力构建更好的数据集
    Vmware 扩展硬盘空间后的操作-Ubuntu
    WEB前端和JAVA薪资前景究竟哪个更高?
    使用Python调用API接口获取京东关键词详情数据
    Android java基础_泛型
    记录python 使用SURF SIRF的问题
    【mysql集群故障恢复】
    诗诺克科技引领数字资产智能交易革命
  • 原文地址:https://blog.csdn.net/hy19930118/article/details/133457283