Redis快速搭建

    1、创建目录文件

    mkdir -p redis/{logs,data,conf}
    chown 999 -R redis/{logs,conf}
    

    2、定义配置文件

    vim redis/conf/redis.conf
    #
    tcp-keepalive 300
    timeout 0 
    loglevel notice
    maxclients 5000
    maxmemory 2G
    maxmemory-policy allkeys-lru
    logfile "/opt/logs/redis.log"
    port 1379
    bind 0.0.0.0
    pidfile /opt/logs/reids.pid
    daemonize no
    cluster-enabled yes
    cluster-config-file /opt/conf/nodes.conf
    cluster-node-timeout 10000
    appendonly yes
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 10mb
    dir /data
    masterauth test2021
    requirepass test2021
    

    3、定义编排文件

    vim redis/docker-compose.yaml
    #
    version: "3.1"
    services:
      redis-master:
        container_name: redis-master
        image: daocloud.io/library/redis:5.0.9
        command: [ "redis-server", "/opt/conf/redis.conf" ]
        restart: always
        network_mode: "host"
        volumes:
          - ./conf:/opt/conf
          - ./logs:/opt/logs
          - ./data:/data
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 50000
            hard: 50000