Redis Cluster + tomcat + mysql

背景

在架设国民认证服务的时候,国民认证厂家程式码是基于 Redis Cluster + tomcat + mysql 部署,因考虑到开发环境,我们要求快速部署、快速开发,所以,我考虑用 docker-compose 进行部署。

根据 Redis官网 的提示,为了让 Docker 与 Redis Cluster 兼容,需要使用 Docker 的 host 网路模式

环境

Docker version 19.03.8

docker-compose version 1.28.5

程式码如下:

version: "3.8"

services:
  redis-6371: # 服务名称
    image: redis # 创建容器时所需的镜像
    container_name: redis-6371 # 容器名称
    restart: always # 容器总是重新启动
    network_mode: "host" # host 网络模式
    volumes: # 数据卷,目录挂载
      - /data/docker-redis/redis-cluster/6371/conf/redis.conf:/etc/redis/redis.conf
      - /data/docker-redis/redis-cluster/6371/data:/data
      - /etc/localtime:/etc/localtime:ro
    command: redis-server /etc/redis/redis.conf # 覆盖容器启动后默认执行的命令

  redis-6372:
    image: redis
    container_name: redis-6372
    network_mode: "host"
    volumes:
      - /data/docker-redis/redis-cluster/6372/conf/redis.conf:/etc/redis/redis.conf
      - /data/docker-redis/redis-cluster/6372/data:/data
      - /etc/localtime:/etc/localtime:ro
    command: redis-server /etc/redis/redis.conf

  redis-6373:
    image: redis
    container_name: redis-6373
    network_mode: "host"
    volumes:
      - /data/docker-redis/redis-cluster/6373/conf/redis.conf:/etc/redis/redis.conf
      - /data/docker-redis/redis-cluster/6373/data:/data
      - /etc/localtime:/etc/localtime:ro
    command: redis-server /etc/redis/redis.conf

  redis-6374:
    image: redis
    container_name: redis-6374
    network_mode: "host"
    volumes:
      - /data/docker-redis/redis-cluster/6374/conf/redis.conf:/etc/redis/redis.conf
      - /data/docker-redis/redis-cluster/6374/data:/data
      - /etc/localtime:/etc/localtime:ro
    command: redis-server /etc/redis/redis.conf

  redis-6375:
    image: redis
    container_name: redis-6375
    network_mode: "host"
    volumes:
      - /data/docker-redis/redis-cluster/6375/conf/redis.conf:/etc/redis/redis.conf
      - /data/docker-redis/redis-cluster/6375/data:/data
      - /etc/localtime:/etc/localtime:ro
    command: redis-server /etc/redis/redis.conf

  redis-6376:
    image: redis
    container_name: redis-6376
    network_mode: "host"
    volumes:
      - /data/docker-redis/redis-cluster/6376/conf/redis.conf:/etc/redis/redis.conf
      - /data/docker-redis/redis-cluster/6376/data:/data
      - /etc/localtime:/etc/localtime:ro
    command: redis-server /etc/redis/redis.conf


  mysql:
    restart: always
    image: mysql:5.7.21
    container_name: FIDO_mysql

    ports:
      - 3306:3306

    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: Admin123

    volumes:
      - /data/FIDO/mysql/mysql.conf.d:/etc/mysql/mysql.conf.d
      - /data/FIDO/mysql/lib/mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
      - /data/FIDO/mysql/logs:/logs

  tomcat:
    restart: always
    image: tomcat:8.5
    container_name: FIDO_tomcat

    ports:
      - 8081:8080

    volumes:
      - /data/FIDO/tomcat/webapps:/usr/local/tomcat/webapps
      - /data/FIDO/tomcat/conf/context.xml:/usr/local/tomcat/conf/context.xml
      - /data/FIDO/tomcat/logs:/usr/local/tomcat/logs
      - /etc/localtime:/etc/localtime:ro
    links:
      - mysql:FIDO_mysql
herui

一枚干着DevOps工作的职业命理师

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据