是的
docker-compose up
Kafka在我的家乡。
无论何时我想制作主题,检索我拥有的主题或搜索存储在我使用的主题中的数据
docker run --net=host --rm confluentinc/cp-kafka:latest kafka-topics --describe --topic bar --zookeeper localhost:32181
在Kafka集群部署官方网站上。
然而,我真的想在我的本地存储Kafka,而不是像Kafka码头形象
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-anptcp,就不会有来自kafka集群的侦听端口。
我该怎么办?请让我知道我现在对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
1条答案
按热度按时间cwxwcias1#
如果你在你的主机上运行kafka(和zookeeper),那么,不,你根本不需要docker。
你不应该使用
localhost
在容器的任何连接字符串中,使用容器的外部服务名称并删除network_mode
从配置中。注意:一台机器上的多个代理/Zookeeper没有任何帮助。
或搜索存储在主题中的数据
你不应该用Zookeeper来做那件事