Docker-MySQL-Cluster服务配置

工欲善其事,必先利其器。

前面一篇文章的方式实现集群服务,需要关联的服务很多,所以在这里做了一个归类整理,采用docker-compose 来管理

配置文件:

docker-compose.yml

version: '2.1'

services:
  ndbman:
    container_name: management1
    image: "mysql/mysql-cluster"
    entrypoint: /entrypoint.sh ndb_mgmd
    ports:
        - "3308:3306"
    volumes:
        - ./mysql-cluster.cnf:/etc/mysql-cluster.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=defaultpass
    networks:
      cluster:
        ipv4_address: 192.168.0.2

  datanode1:
    container_name: ndb1
    image: "mysql/mysql-cluster"
    entrypoint: /entrypoint.sh ndbd
    ports:
            - "13306:3306"
    volumes:
       - ./mysql-cluster.cnf:/etc/mysql-cluster.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=defaultpass
    networks:
      cluster:
        ipv4_address: 192.168.0.3

  datanode2:
    container_name: ndb2
    image: "mysql/mysql-cluster"
    entrypoint: /entrypoint.sh ndbd
    ports:
            - "13307:3306"
    volumes:
       - ./mysql-cluster.cnf:/etc/mysql-cluster.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=defaultpass
    networks:
      cluster:
        ipv4_address: 192.168.0.4

  datanode3:
    container_name: ndb3
    image: "mysql/mysql-cluster"
    entrypoint: /entrypoint.sh ndbd
    ports:
            - "13308:3306"
    volumes:
       - ./mysql-cluster.cnf:/etc/mysql-cluster.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=defaultpass
    networks:
      cluster:
        ipv4_address: 192.168.0.5

  datanode4:
    container_name: ndb4
    image: "mysql/mysql-cluster"
    entrypoint: /entrypoint.sh ndbd
    ports:
            - "13309:3306"
    volumes:
       - ./mysql-cluster.cnf:/etc/mysql-cluster.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=defaultpass
    networks:
      cluster:
        ipv4_address: 192.168.0.6

  mysqld:
    container_name: mysql1
    image: "mysql/mysql-cluster"
    entrypoint: /entrypoint.sh mysqld
    ports:
      - "3306:3306"
    volumes:
       - ./mysql-cluster.cnf:/etc/mysql-cluster.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=defaultpass
    networks:
      cluster:
        ipv4_address: 192.168.0.10

  mysqld2:
    container_name: mysql2
    image: "mysql/mysql-cluster"
    entrypoint: /entrypoint.sh mysqld
    ports:
      - "3307:3306"
    volumes:
       - ./mysql-cluster.cnf:/etc/mysql-cluster.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=defaultpass
    networks:
      cluster:
        ipv4_address: 192.168.0.20
networks:
  cluster:
    driver: bridge
    enable_ipv6: false
    ipam:
      driver: default
      config:
      -
        subnet: 192.168.0.0/16

Docker-MySQL-Cluster服务配置_第1张图片
效果图

你可能感兴趣的:(Docker-MySQL-Cluster服务配置)