https://www.macrozheng.com/blog/redis_cluster.html

在搭建Redis集群之前,我们需要修改下Redis的配置文件redis.conf,该文件的下载地址:https://github.com/antirez/redis/blob/5.0/redis.conf

# 开启集群功能
cluster-enabled yes
# 设置运行端口
port 6391
# 设置节点超时时间,单位毫秒
cluster-node-timeout 15000
# 集群内部配置文件
cluster-config-file "nodes-6391.conf"

然后我们需要编写docker-compose.yml文件用于编排6个Redis容器,具体属性的作用可以参考下面的注释;

version: "3"
services:
  redis-master1:
    image: redis:5.0 # 基础镜像
    container_name: redis-master1 # 容器名称
    working_dir: /config # 切换工作目录
    environment: # 环境变量
      - PORT=6391 # 会使用config/nodes-${PORT}.conf这个配置文件
    ports: # 映射端口,对外提供服务
      - 6391:6391 # redis的服务端口
      - 16391:16391 # redis集群监控端口
    stdin_open: true # 标准输入打开
    tty: true # 后台运行不退出
    network_mode: host # 使用host模式
    privileged: true # 拥有容器内命令执行的权限
    volumes:
      - /mydata/redis-cluster/config:/config #配置文件目录映射到宿主机
    entrypoint: # 设置服务默认的启动程序
      - /bin/bash
      - redis.sh
  redis-master2:
    image: redis:5.0
    working_dir: /config
    container_name: redis-master2
    environment:
      - PORT=6392
    ports:
      - 6392:6392
      - 16392:16392
    stdin_open: true
    network_mode: host
    tty: true
    privileged: true
    volumes:
      - /mydata/redis-cluster/config:/config
    entrypoint:
      - /bin/bash
      - redis.sh
  redis-master3:
    image: redis:5.0
    container_name: redis-master3
    working_dir: /config
    environment:
      - PORT=6393
    ports:
      - 6393:6393
      - 16393:16393
    stdin_open: true
    network_mode: host
    tty: true
    privileged: true
    volumes:
      - /mydata/redis-cluster/config:/config
    entrypoint:
      - /bin/bash
      - redis.sh
  redis-slave1:
    image: redis:5.0
    container_name: redis-slave1
    working_dir: /config
    environment:
      - PORT=6394
    ports:
      - 6394:6394
      - 16394:16394
    stdin_open: true
    network_mode: host
    tty: true
    privileged: true
    volumes:
      - /mydata/redis-cluster/config:/config
    entrypoint:
      - /bin/bash
      - redis.sh
  redis-slave2:
    image: redis:5.0
    working_dir: /config
    container_name: redis-slave2
    environment:
      - PORT=6395
    ports:
      - 6395:6395
      - 16395:16395
    stdin_open: true
    network_mode: host
    tty: true
    privileged: true
    volumes:
      - /mydata/redis-cluster/config:/config
    entrypoint:
      - /bin/bash
      - redis.sh
  redis-slave3:
    image: redis:5.0
    container_name: redis-slave3
    working_dir: /config
    environment:
      - PORT=6396
    ports:
      - 6396:6396
      - 16396:16396
    stdin_open: true
    network_mode: host
    tty: true
    privileged: true
    volumes:
      - /mydata/redis-cluster/config:/config
    entrypoint:
      - /bin/bash
      - redis.sh

docker exec -it nexus3 /bin/bash

#进入
java -jar /opt/sonatype/nexus/lib/support/nexus-orient-console.jar

#连接数据库
connect plocal:../sonatype-work/nexus3/db/security admin admin

#查询帐号
select * from user where id = "admin"

#将admin用户密码重置为 admin123 
update user SET password="$shiro1$SHA-512$1024$NE+wqQq/TmjZMvfI7ENh/g==$V4yPw8T64UQ6GfJfxYq2hLsVrBY8D1v+bktfOxGdt4b/9BthpWPNUy/CBk6V9iA0nHpzYzJFWO8v/tZFtES8CA==" UPSERT WHERE id="admin"

#重启nexus3 
docker restart nexus3 

#停止 nexus服务和启动,感觉无用(进数据库前后)
#/opt/sonatype/nexus/bin/nexus stop
#/opt/sonatype/nexus/bin/nexus start

#安装基础框架
dnf install -y gcc
dnf install -y gcc-c++
dnf install -y patch
dnf install -y unzip
dnf install -y automake
dnf install -y tcl
dnf install -y cmake
dnf install -y perl-FindBin
#获取代码,编译发布
git clone -b develop https://github.com/ossrs/srs.git && cd srs/trunk && ./configure && make

server
{
  server_name   login.xxx.cn;
  include  /common/all_xxx.cn.conf;
  location / {
    root    /;
    proxy_buffering off;
    proxy_request_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;

    proxy_ignore_client_abort on;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 6000;
    proxy_pass    http://192.168.100.1:8081/;
  }
}

docker pull zlmediakit/zlmediakit:pr-8

# 创建 zlmediakit 目录
sudo mkdir -p /data/zlmediakit && sudo chown -R 200 /data/zlmediakit

sudo docker run -d --name zlmediakit -p 1935:1935 -p 7080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:pr-8
sudo docker cp -a zlmediakit:/opt/media /data/zlmediakit

sudo docker rm -f zlmediakit &&
sudo docker run -d --name zlmediakit \
  -p 1935:1935 \
  -p 7080:80 \
  -p 8443:443 \
  -p 8554:554 \
  -p 10000:10000 \
  -p 10000:10000/udp \
  -p 8000:8000/udp -p 9000:9000/udp \
  --network mynetwork \
  --restart=always \
  --env MODE=standalone \
  -e TZ="Asia/Shanghai" \
  -v /data/zlmediakit/media/bin:/opt/media/bin \
  -v /data/zlmediakit/media/conf:/opt/media/conf \
  zlmediakit/zlmediakit:pr-8