[英]Dockerized Kafka TimeoutException with localhost
Hi I got an issue with my dockerized kafka server. 嗨,我的dockerized kafka服务器出现问题。 It does not create messages when send by kafka-console-producer.bat to localhost The eror message is:
当通过kafka-console-producer.bat发送到本地主机时,它不会创建消息。错误消息是:
ERROR Error when sending message to topic test with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback) org.apache.kafka.common.errors.TimeoutException: Topic test not present in metadata after 60000 ms. 错误将消息发送给主题测试的错误,键为:null,值:2个字节,错误为:(org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)org.apache.kafka.common.errors.TimeoutException:主题测试未60000毫秒后出现在元数据中。
The zookeeper and kafka servers are running fine and my yml looks like this: zookeeper和kafka服务器运行正常,我的yml如下所示:
version: '3'
services:
zookeeper:
image: zookeeper
ports:
- 2181:2181
networks:
- test
kafka:
image: kafka:0.1
hostname: kafka
ports:
- 9092:9092
environment:
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_LISTENERS=DOCKER_INTERNAL://kafka:29092,LOCALHOST://localhost:9092
- KAFKA_ADVERTISED_LISTENERS=DOCKER_INTERNAL://kafka:29092,LOCALHOST://localhost:9092
- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=DOCKER_INTERNAL:PLAINTEXT,LOCALHOST:PLAINTEXT
- KAFKA_INTER_BROKER_LISTENER_NAME=DOCKER_INTERNAL
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
- test
networks:
test:
The kafka dockerfile basically just writes the properties to the config/server.properties of kafka and executes kafka-server-start.sh from the latest kafka distribution 2.12-2.3.0 kafka dockerfile基本上只将属性写入kafka的config / server.properties中,并从最新的kafka发行版2.12-2.3.0执行kafka-server-start.sh。
I created a topic during start up and that is retrievable from zookeeper properly: .\\kafka-topics.bat --describe --topic outbound --zookeeper localhost:2181 Result: 我在启动期间创建了一个主题,可以从zookeeper正确检索该主题:。\\ kafka-topics.bat --describe --topic outbound --zookeeper localhost:2181结果:
Topic:inbound PartitionCount:1 ReplicationFactor:1 Configs:
Topic: inbound Partition: 0 Leader: 1 Replicas: 1 Isr: 1
But even using this topic to write a message I get the same error as with a new topic. 但是,即使使用此主题来编写消息,我也会遇到与新主题相同的错误。
Maybe someone had a similar issue, Christian 也许有人遇到过类似的问题,克里斯蒂安
I got it to work :) So the kafka localhost listener has to bind to all interfaces (maybe something to do with the docker network bridge but I am not sure). 我让它工作了:)因此,kafka localhost侦听器必须绑定到所有接口(也许与docker网络桥有关,但我不确定)。 So the yml property is: KAFKA_LISTENERS=DOCKER_INTERNAL://kafka:29092,LOCALHOST://:9092 KAFKA_ADVERTISED_LISTENERS=DOCKER_INTERNAL://kafka:29092,LOCALHOST://localhost:9092
因此yml属性为:KAFKA_LISTENERS = DOCKER_INTERNAL:// kafka:29092,LOCALHOST://:9092 KAFKA_ADVERTISED_LISTENERS = DOCKER_INTERNAL:// kafka:29092,LOCALHOST:// localhost:9092
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.