Kafdrop - 无法使用 bitnami/kafka 连接到 Kafka 集群设置
Kafdrop - Cannot connect to Kafka Cluster setup using bitnami/kafka
我使用 bitnami kafka 和 zookeeper 设置了一个 kafka 集群,我想使用 kafdrop 查看这个集群或至少一个代理。我使用 docker compose 来构建所有组件。我最初遵循这个 tutorial 然后在 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
我尝试用 ff 值更改 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-server1:9092,kafka-server2:9093,kafka-server3:9094
我实际上只是在猜测正确的配置语法,所以对这个的任何解释表示赞赏:)。
此外,是否需要在 kafdrop 配置中添加 networks
属性? Kafdrop 有示例 docker-compose 文件,而这个没有网络配置,所以我想知道是否需要 why/if network
。
你的第二种方法是正确的。对于 KAFKA_CFG_ADVERTISED_LISTENERS
变量,我不确定是否有必要。您只需要确保使用正确的端口即可。这应该可以正常工作:
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://kafka-server1:9092,PLAINTEXT://kafka-server2:9092,PLAINTEXT://kafka-server3:9092"
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
- 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
- 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
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper-server
我使用 bitnami kafka 和 zookeeper 设置了一个 kafka 集群,我想使用 kafdrop 查看这个集群或至少一个代理。我使用 docker compose 来构建所有组件。我最初遵循这个 tutorial 然后在 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
我尝试用 ff 值更改 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-server1:9092,kafka-server2:9093,kafka-server3:9094
我实际上只是在猜测正确的配置语法,所以对这个的任何解释表示赞赏:)。
此外,是否需要在 kafdrop 配置中添加 networks
属性? Kafdrop 有示例 docker-compose 文件,而这个没有网络配置,所以我想知道是否需要 why/if network
。
你的第二种方法是正确的。对于 KAFKA_CFG_ADVERTISED_LISTENERS
变量,我不确定是否有必要。您只需要确保使用正确的端口即可。这应该可以正常工作:
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://kafka-server1:9092,PLAINTEXT://kafka-server2:9092,PLAINTEXT://kafka-server3:9092"
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
- 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
- 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
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper-server