在docker swarm中部署多个zookeepers

时间:2018-05-14 15:54:39

标签: docker apache-kafka cluster-computing apache-zookeeper swarm

我正在尝试使用Docker Swarm部署多个zookeepers(每个都在自己的容器中)。

最终我想使用3名动物园管理员,但现在我只是想让2个实例工作。

我目前的docker-compose.yml:

version: '3'

services:
  zoo1:
    image: zookeeper
    restart: unless-stopped
    hostname: zoo1
    ports:
      - 2181:2181
    environment:
        ZOO_MY_ID: 1
        ZOO_SERVERS: server.1=0.0.0.0:2888:3888;server.2=zoo2:2888:3888
    volumes:
      - ./full-stack/zoo1/data:/data
      - ./full-stack/zoo1/datalog:/datalog
    networks:
      - kafka_network

  zoo2:
    image: zookeeper
    restart: unless-stopped
    hostname: zoo2
    ports:
      - 2182:2181
    environment:
        ZOO_MY_ID: 2
        ZOO_SERVERS: server.1=zoo1:2888:3888;server.2=0.0.0.0:2888:3888
    volumes:
      - ./full-stack/zoo2/data:/data
      - ./full-stack/zoo2/datalog:/datalog
    networks:
      - kafka_network

  visualizer:
    image: dockersamples/visualizer:stable
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    ports:
      - "8080:8080"
    deploy:
      placement:
        constraints: [node.role == manager]

networks:
  kafka_network:
    external:
      name: kafkaNetwork

kafkaNetwork是我使用命令

创建的覆盖网络
docker network create -d overlay --attachable kafkaNetwork

我找到了以下docker论坛帖子https://forums.docker.com/t/cannot-get-zookeeper-to-work-running-in-docker-using-swarm-mode/27109/3但是无法成功让我的zookeeper实例工作。

1 个答案:

答案 0 :(得分:0)

解决。

let s = "A long-running line of '80s ads urged potential pizza customers to “avoid” what?"
let search = s.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)

if let search = search, let url = URL(string: "https://www.google.com/search?q=\(search)"), NSWorkspace.shared.open(url) {
    print("default browser was successfully opened")
} else {
    print("Can't create search URL with \(search)")
}