在两台机器上用docker swarm 部署分布式,执行完容器启动失败

环境设计:两台服务器demo1,demo2 通过docker-swarm 实现分布式部署。

          |      meta    |  storag     |     graph

 demo1    |      meta0    |  storag0   |     graph
   demo2  |      meta1    |   storage1 |     ----
   demo2  |      meta2   |   storage2 |     ----

yml 文件

version: '3.6'
services:
  metad0:
    image: vesoft/nebula-metad:nightly
    env_file:
      - ./nebula.env
    command:
      - --meta_server_addrs=120.46.147.1:9559,120.46.219.2:9559,120.46.219.2:9558
      - --local_ip=120.46.147.1
      - --ws_ip=120.46.147.1
      - --port=9559
      - --data_path=/data/meta
      - --log_dir=/logs
      - --v=0
      - --minloglevel=2
    healthcheck:
      test: ["CMD", "curl", "-f", "http://120.46.147.1:19559/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "19559:19559"
      - "19560:19560"  
      - "9559:9559"      
    volumes:
      - /data/nebula/meta0:/usr/local/nebula/data
      - /data/nebula/meta0/logs:/usr/local/nebula/logs
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.hostname == demo1    
    networks:
      - nebula-net

  metad1:
    image: vesoft/nebula-metad:nightly
    env_file:
      - ./nebula.env
    command:
      - --meta_server_addrs=120.46.147.1:9559,120.46.219.2:9559,120.46.219.2:9558
      - --local_ip=120.46.219.2
      - --ws_ip=120.46.219.2
      - --port=9559
      - --data_path=/data/meta
      - --log_dir=/logs
      - --v=0
      - --minloglevel=2
    healthcheck:
      test: ["CMD", "curl", "-f", "http://120.46.219.2:19559/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "19559:19559"
      - "19560:19560"  
      - "9559:9559"  
    volumes:
      - /data/nebula/meta1:/usr/local/nebula/data
      - /data/nebula/meta1/logs:/usr/local/nebula/logs
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.hostname == demo2      
    networks:
      - nebula-net
      
  metad2:
    image: vesoft/nebula-metad:nightly
    env_file:
      - ./nebula.env
    command:
      - --meta_server_addrs=120.46.147.1:9559,120.46.219.2:9559,120.46.219.2:9558
      - --local_ip=120.46.219.2
      - --ws_ip=120.46.219.2
      - --port=9558
      - --data_path=/data/meta
      - --log_dir=/logs
      - --v=0
      - --minloglevel=2
    healthcheck:
      test: ["CMD", "curl", "-f", "http://120.46.219.2:19558/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "19558:19559"
      - "19561:19560"  
      - "9558:9559"  
    volumes:
      - /data/nebula/meta2:/usr/local/nebula/data
      - /data/nebula/meta2/logs:/usr/local/nebula/logs
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.hostname == demo2
    networks:
      - nebula-net

  storaged0:
    image: vesoft/nebula-storaged:nightly
    env_file:
      - ./nebula.env
    command:
      - --meta_server_addrs=120.46.147.1:9559,120.46.219.2:9559,120.46.219.2:9558
      - --local_ip=120.46.147.1
      - --ws_ip=120.46.147.1
      - --port=9779
      - --data_path=/data/storage
      - --log_dir=/logs
      - --v=0
      - --minloglevel=2
    healthcheck:
      test: ["CMD", "curl", "-f", "http://120.46.147.1:19779/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "9779:9779"
      - "19779:19779"
      - "19780:19780"
    volumes:
      - data-storaged0:/data/storage
      - logs-storaged0:/logs
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.hostname == demo1
    depends_on:
      - metad0
      - metad1
      - metad2          
    networks:
      - nebula-net
  storaged1:
    image: vesoft/nebula-storaged:nightly
    env_file:
      - ./nebula.env
    command:
      - --meta_server_addrs=120.46.147.1:9559,120.46.219.2:9559,120.46.219.2:9558
      - --local_ip=120.46.219.2
      - --ws_ip=120.46.219.2
      - --port=9779
      - --data_path=/data/storage
      - --log_dir=/logs
      - --v=0
      - --minloglevel=2
    healthcheck:
      test: ["CMD", "curl", "-f", "http://120.46.219.2:19779/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "9779:9779"
      - "19779:19779"
      - "19780:19780"
    volumes:
      - data-storaged1:/data/storage
      - logs-storaged1:/logs
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.hostname == demo2
    depends_on:
      - metad0
      - metad1
      - metad2          
    networks:
      - nebula-net
  storaged2:
    image: vesoft/nebula-storaged:nightly
    env_file:
      - ./nebula.env
    command:
      - --meta_server_addrs=120.46.147.1:9559,120.46.219.2:9559,120.46.219.2:9558
      - --local_ip=120.46.219.2
      - --ws_ip=120.46.219.2
      - --port=9778
      - --data_path=/data/storage
      - --log_dir=/logs
      - --v=0
      - --minloglevel=2
    healthcheck:
      test: ["CMD", "curl", "-f", "http://120.46.219.2:19778/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "9778:9779"
      - "19778:19779"
      - "19781:19780"
    volumes:
      - data-storaged2:/data/storage
      - logs-storaged2:/logs
    depends_on:
      - metad0
      - metad1
      - metad2
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.hostname == demo2      
    networks:
      - nebula-net
      
  graphd:
    image: vesoft/nebula-graphd:nightly
    env_file:
      - ./nebula.env
    command:
      - --meta_server_addrs=120.46.147.1:9559,120.46.219.2:9559,120.46.219.2:9558
      - --port=9669
      - --ws_ip=120.46.147.1
      - --log_dir=/logs
      - --v=0
      - --minloglevel=2
    healthcheck:
      test: ["CMD", "curl", "-f", "http://120.46.147.1:19669/status"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
    ports:
      - "9669:9669"
      - "19669:19669"
      - "19670:19670"
    volumes:
      - logs-graphd:/logs
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.hostname == demo1
    depends_on:
      - metad0
      - metad1
      - metad2
    networks:
      - nebula-net
      
networks:
  nebula-net:
    external: true
    attachable: true
    name: host

执行完后报错:
meta0 和meta1 的端口冲突
yml 保留 meta0 ,graphd ,storaged0改为单个服务器启动时,容器一直处于创建中——失败——创建的状态

用swarm实现分布式不同服务器部署, yml文件有什么问题吗?

meta 默认的端口号 应该是 9559,你确定下这个端口号是不是没问题。

没有问题 ,120.46.219.2 服务器上想启动两个容器 一个端口9559,另一个9558

启动一台服务器 一个容器的配置时,启动失败,去掉command和端口配置才能正常启动

那我知道原因了,你把 9558 这个端口号改成别的,我记得一个 meta 服务会占有附近的几个端口用来监听服务,即,你如果 meta 的服务端口号是 9559,9558 和 9560 都是不能用的。

建议你把端口号隔开点。

此话题已在 188 天后被自动关闭。不再允许新回复。