为什么我应该将docker映像“ confluentinc / kafka”用于kafka集群?

问题描述 投票:0回答:1

我做了

docker-compose up

用于在我的本地进行kafka群集。

并且每当我要创建主题时,检索我拥有的主题或搜索存储在我使用的主题中的数据

docker run --net=host --rm confluentinc/cp-kafka:latest kafka-topics --describe --topic bar --zookeeper localhost:32181

位于官方的kafka群集部署站点上。

但是我真的想在我的本地存储中使用Kafka,而不是像kafka docker镜像那样>​​>

kafka-topics --describe --topic bar --zookeeper localhost:32181

如果我使用上面的代码,我将遇到此错误。

Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
        at kafka.zookeeper.ZooKeeperClient.$anonfun$waitUntilConnected$3(ZooKeeperClient.scala:258)

除了我是否检查netstat -anp tcp

kafka集群中没有LISTEN端口。

我该怎么办?并且请让我知道我现在关于docker的缺失(因为我真的是docker的新手:()

这是Yaml配置

---
version: '2'
services:
  zookeeper-1:
    image: confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_SERVER_ID: 1
      ZOOKEEPER_CLIENT_PORT: 22181
      ZOOKEEPER_TICK_TIME: 2000
      ZOOKEEPER_INIT_LIMIT: 5
      ZOOKEEPER_SYNC_LIMIT: 2
      ZOOKEEPER_SERVERS: localhost:22888:23888;localhost:32888:33888;localhost:42888:43888
    network_mode: host
    extra_hosts:
      - "moby:127.0.0.1"

  zookeeper-2:
    image: confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_SERVER_ID: 2
      ZOOKEEPER_CLIENT_PORT: 32181
      ZOOKEEPER_TICK_TIME: 2000
      ZOOKEEPER_INIT_LIMIT: 5
      ZOOKEEPER_SYNC_LIMIT: 2
      ZOOKEEPER_SERVERS: localhost:22888:23888;localhost:32888:33888;localhost:42888:43888
    network_mode: host
    extra_hosts:
      - "moby:127.0.0.1"

  zookeeper-3:
    image: confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_SERVER_ID: 3
      ZOOKEEPER_CLIENT_PORT: 42181
      ZOOKEEPER_TICK_TIME: 2000
      ZOOKEEPER_INIT_LIMIT: 5
      ZOOKEEPER_SYNC_LIMIT: 2
      ZOOKEEPER_SERVERS: localhost:22888:23888;localhost:32888:33888;localhost:42888:43888
    network_mode: host
    extra_hosts:
      - "moby:127.0.0.1"

  kafka-1:
    image: confluentinc/cp-kafka:latest
    network_mode: host
    depends_on:
      - zookeeper-1
      - zookeeper-2
      - zookeeper-3
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: localhost:22181,localhost:32181,localhost:42181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:19092
    extra_hosts:
      - "moby:127.0.0.1"

  kafka-2:
    image: confluentinc/cp-kafka:latest
    network_mode: host
"docker-compose.yml" 83L, 2321C

我做了docker-compose来在我的本地进行kafka集群。并且每当我要创建主题时,检索我拥有的主题或搜索存储在该主题中的数据,我都使用docker run --net = host --rm ...

docker apache-kafka docker-compose confluent kafka-cluster
1个回答
0
投票

如果您在主机上运行Kafka(和Zookeeper),那么,不,您根本不需要Docker。

© www.soinside.com 2019 - 2024. All rights reserved.