我正在尝试制作具有wurstmeister / zookeeper和wurstmeister / kafka的dockerfile。如果我在计算机上运行使用者和生产者,那么一切都可以正常运行(我在终端上运行zookeeper和kafka)。但是,当我使用此zookeper和kafka时,我的意思是当我运行此dockerfile时,出现此错误
o.a.k.c.consumer.internals.Fetcher - [Consumer clientId=consumer-1, groupId=consumerGroup1] Topic metadata fetch included errors: {log-monitoring=LEADER_NOT_AVAILABLE}
我认为有关网络的问题,他们在docker上找不到彼此。 这是我的docker-compose.yml
zookeeper:
image: wurstmeister/zookeeper
container_name: "zk"
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
container_name: "kafka"
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100
KAFKA_ZOOKEEPER_CONNECT: zk:2181
KAFKA_CREATE_TOPICS: "log-monitoring"
links:
- zookeeper:zk
volumes:
- /var/run/docker.sock:/var/run/docker.sock
mongo:
image: mongo
container_name: "mongo"
ports:
- "27017:27017"
producer:
image: berat703/kafka-producer:0.0.3
container_name: "producer"
environment:
- KAFKA_BROKER=kafka:9092
links:
- kafka:kafka
consumer:
image: berat703/kafka-consumer:0.0.2
container_name: "consumer"
ports:
- "8080:8080"
environment:
- KAFKA_BROKER=kafka:9092
- MONGODB_HOST=mongo
- MONGODB_PORT=27017
links:
- kafka:kafka
答案 0 :(得分:0)
尝试将KAFKA_ADVERTISED_HOST_NAME
更改为kafka的FQDN,即。 kafka
。无论您放在哪里,生产者都可以解决。该字段也已弃用,建议改用KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
之类的内容。