Docker Compse cluster Mongo is highly available

Distribution diagram of one and three servers and Mongo nodes

10.11.32.25 | 10.11.32.26 | 10.11.32.27

1-2 | | 1-1-3

2-3 | | 2-1-2

3-3 | | 3-1, 3-2

config1 | congig2 | congif3

mongos1 | mongos2 | mongos3

Second, mongo node configuration file

--------------------------------------------------------------------1 1
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
​
services:
​
​
  prod-mongo-rs-1-1:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-1-1
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/conf:/etc/mongo/
    ports:
      - "57117:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
​
    entrypoint:
      - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
​
​
--------------------------------------------------------------------1 2
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongo-rs-1-2:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-1-2
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/conf:/etc/mongo/
    ports:
      - "57117:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
    entrypoint:
      - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
​
--------------------------------------------------------------------1-arb
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
​
  prod-mongo-rs-1-arb:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-1-arb
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard1/conf:/etc/mongo/
    ports:
      - "57117:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
    privileged: true
​
​
​
--------------------------------------------------------------------2 1
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongo-rs-2-1:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-2-1
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/conf:/etc/mongo/
    ports:
      - "57217:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
​
    entrypoint:
      - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
​
​
--------------------------------------------------------------------2 2
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongo-rs-2-2:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-2-2
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/conf:/etc/mongo/
    ports:
      - "57217:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
​
    entrypoint:
      - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
​
--------------------------------------------------------------------2-arb
​
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
​
  prod-mongo-rs-2-arb:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-2-arb
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard2/conf:/etc/mongo/
    ports:
      - "57217:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
    privileged: true
​
​
--------------------------------------------------------------------3 1
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongo-rs-3-1:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-3-1
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/conf:/etc/mongo/
    ports:
      - "57317:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
​
    entrypoint:
      - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
​
--------------------------------------------------------------------3 2
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongo-rs-3-2:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-3-2
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/conf:/etc/mongo/
    ports:
      - "57317:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
​
    entrypoint:
      - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
​
--------------------------------------------------------------------3-arb
​
version: '3.4'
networks:
  GIE-ECP-overlay-network:
    external: true
services:
​
  prod-mongo-rs-3-arb:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongo-rs-3-arb
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/backup:/data/backup/
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/shard3/conf:/etc/mongo/
    ports:
      - "57317:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
    privileged: true
    
    
--------------------------------------------------------------------1-config
​
version: '3.4'
​
networks:
  GIE-ECP-overlay-network:
    external: true
​
services:
​
  prod-mongo-rs-config-1:
    image: 10.11.32.23:5000/mongo:v4.4.3
​
    container_name: prod-mongo-rs-config-1
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/config1/backup:/data/backup
      - /data/docker/composes/prod/middleware/mongo_cluster/config1/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/config1/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/config1/conf:/data/conf
    ports:
      - "27117:27117"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
    privileged: true
​
​
​
--------------------------------------------------------------------2-config
version: '3.4'
​
networks:
  GIE-ECP-overlay-network:
    external: true
services:
​
  prod-mongo-rs-config-2:
    image: 10.11.32.23:5000/mongo:v4.4.3
​
    container_name: prod-mongo-rs-config-2
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/backup:/data/backup
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/conf:/data/conf
    ports:
      - "27117:27117"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
    privileged: true
​
--------------------------------------------------------------------3-config
​
version: '3.4'
​
networks:
  GIE-ECP-overlay-network:
    external: true
services:
​
  prod-mongo-rs-config-2:
    image: 10.11.32.23:5000/mongo:v4.4.3
​
    container_name: prod-mongo-rs-config-2
    networks:
      - GIE-ECP-overlay-network
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/backup:/data/backup
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/config2/conf:/data/conf
    ports:
      - "27117:27117"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - numactl
    command:
      - --interleave=all
      - mongod
      - --config
      - /etc/mongo/mongo.conf
    privileged: true
​
​
•   
--------------------------------------------------------------------mongs 1
​
version: '3.4'
​
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongos-1:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongos-1
    networks:
      GIE-ECP-overlay-network:
        aliases:
          - prod-mongos-1
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos1/backup:/data/backup
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos1/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos1/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos1/conf:/data/conf
    ports:
      - "27017:27017"
      - "57017:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - mongos
    command:
      - --configdb
      - rs_config_server/prod-mongo-rs-config-1:27117,prod-mongo-rs-config-2:27117,prod-mongo-rs-config-3:27117
      - --bind_ip_all
​
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
​
​
--------------------------------------------------------------------mongs 2
​
version: '3.4'
​
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongos-2:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongos-2
    networks:
      GIE-ECP-overlay-network:
        aliases:
          - prod-mongos-2
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos2/backup:/data/backup
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos2/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos2/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos2/conf:/data/conf
    ports:
      - "27017:27017"
      - "57017:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - mongos
    command:
      - --configdb
      - rs_config_server/prod-mongo-rs-config-1:27117,prod-mongo-rs-config-2:27117,prod-mongo-rs-config-3:27117
      - --bind_ip_all
​
    privileged: true
    ulimits:
      nproc: 65535
      nofile:
        soft: 64000
        hard: 64000
​
--------------------------------------------------------------------mongs 3
​
version: '3.4'
​
networks:
  GIE-ECP-overlay-network:
    external: true
services:
  prod-mongos-2:
    image: 10.11.32.23:5000/mongo:v4.4.3
    container_name: prod-mongos-3
    networks:
      GIE-ECP-overlay-network:
        aliases:
          - prod-mongos-3
    volumes:
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos3/backup:/data/backup
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos3/log:/data/log
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos3/data:/data/db
      - /data/docker/composes/prod/middleware/mongo_cluster/mongos3/conf:/data/conf
    ports:
      - "27017:27017"
      - "57017:27017"
    environment:
      - TZ=Asia/Shanghai
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/data/logs
    entrypoint:
        - mongos
    command:
      - --configdb
      - rs_config_server/prod-mongo-rs-config-1:27117,prod-mongo-rs-config-2:27117,prod-mongo-rs-config-3:27117
      - --bind_ip_all
      privileged: true
        ulimits:
          nproc: 65535
          nofile:
            soft: 64000
            hard: 64000
Copy the code