从docker-compose我得到了这个yml:
version: '2'
services:
zookeeper:
container_name: zookeeper
image: confluentinc/cp-zookeeper:3.1.1
ports:
- "2080:2080"
environment:
- ZOOKEEPER_CLIENT_PORT=2080
- ZOOKEEPER_TICK_TIME=2000
kafka:
container_name: kafka
image: confluentinc/cp-kafka:3.1.1
ports:
- "9092:9092"
environment:
- KAFKA_CREATE_TOPICS=Topic1:1
- KAFKA_ZOOKEEPER_CONNECT=192.168.99.100:2080
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.99.100:9092
depends_on:
- zookeeper
schema-registry:
container_name: schema-registry
image: confluentinc/cp-schema-registry:3.1.1
ports:
- "8081:8081"
environment:
- SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=192.168.99.100:2080
- SCHEMA_REGISTRY_HOST_NAME=localhost
depends_on:
- zookeeper
- kafka
当我站起来时,控制台输出结束于:
schema-registry | Error while running kafka-ready.
schema-registry | org.apache.kafka.common.errors.TimeoutException: Timed out waiting for Kafka to create /brokers/ids in Zookeeper. timeout (ms) = 40000
schema-registry exited with code 1
似乎kafka从未连接过Zookeper或类似的东西,有谁知道为什么会这样?
答案 0 :(得分:0)
要更改
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=192.168.99.100:2080
进入
SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL=zookeeper:2080
帮助?
此外,KAFKA_ZOOKEEPER_CONNECT=192.168.99.100:2080
还应提及zookeeper
,而不是IP地址。或者,您如何确定该IP地址?
KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.99.100:9092
提到了您可能也无法保证的IP地址。对于后者,可以将该IP地址更改为kafka
。
在让Kafka和Zookeeper在Docker中工作(通过Docker Compose)方面,我也遇到了挑战。最后,https://github.com/confluentinc/cp-docker-images/blob/5.0.0-post/examples/kafka-single-node/docker-compose.yml为我工作。您可以将其用作灵感来源。