【swarm】swarm服务部署的编排文件

用swarm集群形式部署MySQL服务

 

# cat mysql.yml

##########################################################

version: "3"
services:

  mysql:
    image: mysql:5.7.28
    deploy:
      replicas: 1
      resources:
        limits:
          cpus: '1'
          memory: 1G
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
      placement:
        constraints:
          - node.labels.key==value
    environment:
      - MYSQL_ROOT_PASSWORD: "MySQL@123"
    volumes:
      - /opt/mysqldata:/var/lib/mysql
    ports:
      - "3306:3306"
    logging:
      driver: gelf
      options:
        gelf-address: udp://logstash:12201

##NETWORK###
networks:
  default:
      driver: overlay

  nexus:
    image: sonatype/nexus3
    deploy:
      replicas: 1
      resources:
        limits:
          cpus: '1'
          memory: 2G
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
      placement:
        constraints:
        - node.labels.key==value
    volumes:
      - /opt/nexusdata:/nexus-data
    ports:
      - "8081:8081"

##NETWORK###
networks:
  default:
    driver: overlay
 

##########################################################

 

【swarm】swarm服务部署的编排文件_第1张图片

 


# docker stack deploy test -c docker.yml --with-registry-auth

 

# docker service ls 

 

 

 

参考

 

从docker单机到swarm模式的网络变化

https://www.jianshu.com/p/26e13631d625

 

Docker Swarm - 节点标签与服务约束

https://www.jianshu.com/p/2a11a40a9573

 

用docker swarm部署ELK日志系统

https://www.jianshu.com/p/ff4811c79985

 

CentOS7.x上swarm部署kong

https://www.jianshu.com/p/12b026dd006d

 

Send docker logs to ELK through gelf log driver

https://docs.docker.com/config/containers/logging/gelf

https://gist.github.com/eunomie/e7a183602b8734c47058d277700fdc2d#send-docker-logs-to-elk-through-gelf-log-driver

 

 

你可能感兴趣的:(swarm,MySQL)