这个问题在这里已经有答案了:
连接Kafka在docker中跑步(3个答案)
4个月前关门了。
我使用bitnami-kafka和zookeeper设置了一个kafka集群,我想使用kafdrop查看这个集群或至少一个代理。我使用docker compose构建所有组件。我最初遵循本教程,然后在docker-compose.yml中添加了kafdrop配置
version: '2'
networks:
kafka-net:
driver: bridge
services:
zookeeper-server:
image: 'bitnami/zookeeper:latest'
networks:
- kafka-net
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafdrop:
image: obsidiandynamics/kafdrop
networks:
- kafka-net
restart: "no"
ports:
- "9000:9000"
environment:
KAFKA_BROKERCONNECT: "PLAINTEXT://localhost:9092,PLAINTEXT://localhost:9093,PLAINTEXT://localhost:9094"
JVM_OPTS: "-Xms16M -Xmx48M -Xss180K -XX:-TieredCompilation -XX:+UseStringDeduplication -noverify"
depends_on:
- "kafka-server1"
- "kafka-server2"
- "kafka-server3"
kafka-server1:
image: 'bitnami/kafka:latest'
networks:
- kafka-net
ports:
- '9092:9092'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper-server
kafka-server2:
image: 'bitnami/kafka:latest'
networks:
- kafka-net
ports:
- '9093:9092'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9093
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper-server
kafka-server3:
image: 'bitnami/kafka:latest'
networks:
- kafka-net
ports:
- '9094:9092'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9094
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper-server
我的主要问题是kafdrop总是抛出以下错误:
020-08-26 10:53:53.517 WARN 1 [| kafdrop-admin] o.a.k.c.NetworkClient : [AdminClient clientId=kafdrop-admin] Connection to node -3 (localhost/127.0.0.1:9094) could not be established. Broker may not be available.
2020-08-26 10:53:53.522 WARN 1 [| kafdrop-admin] o.a.k.c.NetworkClient : [AdminClient clientId=kafdrop-admin] Connection to node -2 (localhost/127.0.0.1:9093) could not be established. Broker may not be available.
2020-08-26 10:53:53.526 WARN 1 [| kafdrop-admin] o.a.k.c.NetworkClient : [AdminClient clientId=kafdrop-admin] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
2020-08-26 10:53:53.627 WARN 1 [| kafdrop-admin] o.a.k.c.NetworkClient : [AdminClient clientId=kafdro
我试过改变 KAFKA_BROKERCONNECT
但都不起作用。
plaintext://localhost:9092,plaintext://localhost:9093,plaintext://localhost:9094
localhost:9092,localhost:9093,localhost:9094
plaintext://kafka-server1:9092,plaintext://kafka-server2:9093,plaintext://kafka-server3:9094
Kafka服务器1:9092、Kafka服务器2:9093、Kafka服务器3:9094
实际上,我只是猜测正确的配置语法,所以任何与此相关的解释都是值得赞赏的:)。
此外,还添加了 networks
kafdrop配置需要属性吗?kafdrop有示例docker compose文件,而这个文件没有网络配置,所以我想知道为什么/如果 network
是需要的。
1条答案
按热度按时间baubqpgj1#
你的第二条路是正确的。同样适用于
KAFKA_CFG_ADVERTISED_LISTENERS
我不确定是否需要VAR。你只需要确保使用正确的端口。这应该很管用: