为什么我应该使用 docker image "confluentinc/kafka" 到 kafka 集群?
why should i use docker image "confluentinc/kafka" to kafka cluster?
我做到了
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(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
如果您的主机上是 运行 Kafka(和 Zookeeper),那么,不,您根本不需要 Docker。
您不应在容器的任何连接字符串中使用 localhost
,而应使用容器的外部服务名称并从配置中删除 network_mode
。
注意:一台机器上的多个 brokers/zookeepers 没有任何帮助。
or search data stored in the topic
你不应该使用 zookeeper 来做那个
我做到了
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(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
如果您的主机上是 运行 Kafka(和 Zookeeper),那么,不,您根本不需要 Docker。
您不应在容器的任何连接字符串中使用 localhost
,而应使用容器的外部服务名称并从配置中删除 network_mode
。
注意:一台机器上的多个 brokers/zookeepers 没有任何帮助。
or search data stored in the topic
你不应该使用 zookeeper 来做那个