Docker-compose编排MySQL+Nacos+Seata

本文详细介绍了如何使用Docker-compose部署MySQL、Nacos和Seata,涉及环境依赖、配置步骤及异常处理。在配置过程中,强调了应用配置文件的重要性,特别是MySQL、Seata与Nacos的连接设置,以及遇到的如endpoint为空、数据库连接异常、Nacos连接重试错误等问题的解决方案。
摘要由CSDN通过智能技术生成

环境依赖

Nacos:v2.1.0

MySQL:8.0.21

Seata:1.5.0

nacos依赖MySql;

Seata依赖Nacos+Mysql

涉及到的点

deploy部署设置、depends_on执行顺序设置、自定义网段

完整配置

version: '3.9'
services:
  #mysql数据库脚本
  db:
    image: mysql:8.0.21
    container_name: mysql
    hostname: mysql-node1 
    restart: always
    ports:
      - 3306:3306
    volumes:
      - ./mysql/logs:/var/log/mysql
      - ./mysql/data:/var/lib/mysql
      - ./mysql/conf/my.cnf:/etc/my.cnf
      - ./mysql/init:/docker-entrypoint-initdb.d/
    environment:
      MYSQL_ROOT_PASSWORD: ltingzx
    healthcheck:
      test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
      interval: 5s
      timeout: 5s
      retries: 2
      start_period: 5s
    security_opt:
      - seccomp:unconfined
    networks:
      extnetwork:
        ipv4_address: 172.21.0.2 
  #nacos服务脚本
  nacos:
    image: nacos/nacos-server:v2.1.0
    container_name: nacos
    hostname: nacos-node1
    restart: always
    ports:
      - "8848:8848"
    volumes: #挂载目录
      - ./nacos/logs/:/home/nacos/logs
      - ./nacos/data/:/home/nacos/data
    environment:
      SPRING_DATASOURCE_PLATFORM: mysql #数据源平台 仅支持mysql或不保存empty
      MODE: standalone
      MYSQL_SERVICE_HOST: mysql
      MYSQL_SERVICE_DB_NAME: nacos
      MYSQL_SERVICE_PORT: 3306
      MYSQL_SERVICE_USER: root
      MYSQL_SERVICE_PASSWORD: ltingzx
      NACOS_APPLICATION_PORT: 8848
      JVM_XMS: 512m
      JVM_MMS: 256m
      JVM_XMN: 128m
      MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=10000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
    networks:
      extnetwork:
        ipv4_address: 172.21.0.3
    deploy:
      restart_policy:
        delay: 5s
        max_attempts: 10
    healthcheck:
      test: ["CMD-SHELL", "echo 'ruok' | curl -s telnet://localhost:8848 || exit 1"]
      interval: 3s
      timeout: 5s
      retries: 3
      start_period: 5s
    depends_on:
      db:
        #condition: service_started
        condition: service_healthy
        #condition: service_completed_successfully
  #seata服务脚本
  seata:
    image: seataio/seata-server:1.5.0
    container_name: seata-server
    restart: always
    ports:
      - "9200:9200"
      - "7091:7091"
    volumes:
      - ./seata-server/mysql-connector-java-8.0.25.jar:/seata-server/libs/mysql-connector-java-8.0.25.jar
      - ./seata-server/config/application.yml:/seata-server/resources/application.yml
      - ./seata-server/logs:/root/logs/seata
    environment:
      SEATA_IP: 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值