在docker-compose文件中使用Weave net

时间:2019-04-08 10:13:44

标签: docker docker-compose mesos marathon weave

我有一个包含Hadoop,Mesos,Marathon和Zookeeper的docker映像。我将此映像分布在三个物理节点之间。为了运行该映像,我编写了一个包含Zookeeper,Mesos,Marathon的三个服务的docker compose。我使用 WEAVE_CIDR 在撰写文件中编织IP。我为三种服务定义了相同的IP编织。当我运行撰写文件时,Zookeeper运行良好,但是由于重复的IP编织,我在运行Mesos时收到错误消息。因此,我尝试将三个服务合并到一个服务中,以仅对其中三个使用一种IP编织。我的新docker compose如下:

 version: '3.7'
 services:
  zookeeper:
    image: hadoop_marathon_mesos_flink_2
    command: bash -c "echo zookeeper;
    /home/zookeeper-3.4.14/bin/zkServer.sh restart;echo mesos;
    sleep 30;/home/mesos-1.7.2/build/bin/mesos-master.sh;
    echo marathon;/home/marathon-1.7.189-48bfd6000/bin/marathon"
    privileged: true
    network_mode: "bridge"
    environment:
      ZOOKEEPER_SERVER_ID: 1
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
      ZOOKEEPER_INIT_LIMIT: 10
      ZOOKEEPER_SYNC_LIMIT: 5
      WEAVE_CIDR: 10.32.0.1/12
      ZOOKEEPER_SERVERS: 10.32.0.1:2888:3888
      MESOS_CLUSTER: MMM
      LIBPROCESS_IP: 10.32.0.1
      MESOS_QUORUM: 1
      MESOS_LOG_DIR: /var/log/mesos
      MESOS_WORK_DIR: /var/run/mesos
      MESOS_EXECUTOR_REGISTRATION_TIMEOUT: 5mins
      HOSTNAME: 10.32.0.1
      MARATHON_ZK: zk://10.32.0.1:2181/marathon
      MARATHON_MASTER: zk://10.32.0.1:2181/mesos
      MESOS_NATIVE_JAVA_LIBRARY: /usr/local/lib/libmesos.so
      MARATHON_HTTP_PORT: 8080
      Mesos_HTTP_PORT: 5050
    expose:
     - 2181
     - 2888
     - 3888
     - 5050
     - 4040
     - 7077
     - 8080
    ports:
     - 2181:2181
     - 2888:2888
     - 3888:3888
     - 5050:5050
     - 4040:4040
     - 7077:7077
     - 8080:8080

 networks:
  default:
    external:
      name: weave

当我运行 docker-compose up 时,Zookeeper和Mesos正常运行。但是马拉松没有参加。我希望马拉松比赛紧随Mesos之后,但不是。请任何人告诉我我在做什么错了吗?

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

问题解决了。我在主节点中使用了这个docker compose文件。在运行docker compose之前,请在三个节点中运行 weave Exposure 以打开Marathon和Mesos UI。

 version: '3.7'
 services:
  zookeeper:
   image: hadoop_marathon_mesos_flink_2
   command: >
          sh -c "echo zookeeper && 
          /home/zookeeper-3.4.14/bin/zkServer.sh restart && 
          sleep 30 && /home/mesos-1.7.2/build/bin/mesos-master.sh 
          --ip=10.32.0.1 --hostname=10.32.0.1 --roles=marathon,flink |
         /home/marathon-1.7.189-48bfd6000/bin/marathon --master 10.32.0.1:5050 
         --zk zk://10.32.0.1:2181/marathon --hostname 10.32.0.1 
         --webui_url 10.32.0.1:8080 --logging_level debug"
   privileged: true
   network_mode: "bridge"
   environment:
     WEAVE_CIDR: 10.32.0.1/12
     ZOOKEEPER_SERVER_ID: 1
     ZOOKEEPER_CLIENT_PORT: 2181
     ZOOKEEPER_TICK_TIME: 2000
     ZOOKEEPER_INIT_LIMIT: 10
     ZOOKEEPER_SYNC_LIMIT: 5
     ZOOKEEPER_SERVERS: 10.32.0.1:2888:3888
     MESOS_CLUSTER: MMM
     LIBPROCESS_IP: 10.32.0.1
     MESOS_QUORUM: 1
     MESOS_LOG_DIR: /var/log/mesos
     MESOS_WORK_DIR: /var/run/mesos
     MESOS_EXECUTOR_REGISTRATION_TIMEOUT: 5mins
     HOSTNAME: 10.32.0.1
     MESOS_NATIVE_JAVA_LIBRARY: /usr/local/lib/libmesos.so
     MESOS_DOCKER_SOCKET: /var/run/weave/weave.sock
   expose:
    - 2181
    - 2888
    - 3888
    - 5050
    - 4040
    - 7077
    - 8080
   ports:
    - 2181:2181
    - 2888:2888
    - 3888:3888
    - 5050:5050
    - 4040:4040
    - 7077:7077
    - 8080:8080

networks:
 default:
  external:
    name: weave

此外,我在从属节点中运行了这个docker compose:

 version: '3.7'
 services:
   slave:
    image: hadoop_marathon_mesos_flink_2
    command: sh -c "rm -f /var/run/mesos/meta/slaves/latest &&
           /home/mesos-1.7.2/build/bin/mesos-slave.sh --master=10.32.0.1:5050 
         --port=5051 --work_dir=/var/run/mesos  --systemd_enable_support=fa$
         privileged: true
   network_mode: "bridge"
   environment:
     WEAVE_CIDR: 10.32.0.2/12
     MESOS_RESOURCES: ports(*):[11000-11999]
     LIBPROCESS_IP: 10.32.0.2
     MESOS_HOSTNAME: 10.32.0.2
     MESOS_EXECUTOR_REGISTRATION_TIMEOUT: 5mins #also in Dockerfile
     MESOS_LOG_DIR: /var/log/mesos
     MESOS_WORK_DIR: /var/run/mesos
     MESOS_LOGGING_LEVEL: INFO
     MESOS_DOCKER_SOCKET: /var/run/weave/weave.sock
   expose:
    - 5051
   ports:
    - 5051:5051

 networks:
  default:
    external:
      name: weave

希望它有用。