Skip to content
SRE运维进阶之路SRE运维进阶之路
devops
github icon

    Redis 6.x 哨兵安装配置

    author iconClaycalendar icon2023年4月19日category icon
    • Redis
    timer icon小于 1 分钟

    此页内容
    • 1 升级 gcc
    • 2 用 ansible 安装 redis 哨兵

    # Redis 6.x 哨兵安装配置

    # 1 升级 gcc

    centos7 默认的 gcc 默认是4.8.5,版本小于 5.3 无法编译,需要先安装gcc新版才能编译

    yum -y install gcc-c++
    yum -y install centos-release-scl
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
    echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile 
    
    1
    2
    3
    4

    # 2 用 ansible 安装 redis 哨兵

    下载role

    git clone -b dev-clay https://github.com/clay-wangzhi/Ansible-roles.git
    cp -r Ansible-roles/redis5/ /etc/ansible/roles/
    
    1
    2

    Example Playbook

    cat /etc/ansible/playbooks/redis_sentinel.yml

     hosts: 172.16.xx.xx
      vars:
        - redis_version: '6.2.4'
        - redis_master_host: '172.16.xx.xx'
        - redis_master_port: '6380'
        - redis_requirepass: '123456'
        - redis_masterauth: '123456'
        - redis_sentinel_monitors:
          - name: mymaster
            ip: 172.16.xx.xx
            port: 6380
            quorum: 2
            masterauth: '123456'
      roles:
       - { role: redis5, redis_port: 6380 }
       - { role: redis5, redis_port: 6381, redis_slave: true }
       - { role: redis5, redis_port: 6382, redis_slave: true }
       - { role: redis5, redis_port: 16380, redis_sentinel: true }
       - { role: redis5, redis_port: 16381, redis_sentinel: true }
       - { role: redis5, redis_port: 16382, redis_sentinel: true }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

    安装

    ansible-playbook redis_sentinel.yml
    
    1

    参考链接

    • redis6.x哨兵模式安装配置open in new window
    • ansible roles redisopen in new window
    • 使用Systemd启动Redisopen in new window
    edit icon编辑此页open in new window
    上次编辑于: 2023/4/19 13:08:31
    贡献者: clay-wangzhi
    备案号:冀ICP备2021007336号
    Copyright © 2023 Clay