通过docker-compose
启动kafka
配置信息如下
version: "2"
services:
zookeeper:
image: wurstmeister/zookeeper:latest
ports:
- "3181:2181"
network_mode: "bridge"
kafka:
image: wurstmeister/kafka:2.12-2.2.0
ports:
- "9192:9192"
environment:
KAFKA_LISTENERS: PLAINTEXT://192.111.1.1:9192
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_DELETE_TOPIC_ENABLE: "true"
network_mode: "bridge"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
links:
- zookeeper
查看docker日志报错:
ERROR [KafkaServer id=1008] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka_1 | org.apache.kafka.common.KafkaException: Socket server failed to bind to 192.111.1.1:9192: Address not available
前几天我发的是broker创建失败,我删除了好几遍容器、还卸载过镜像和docker重装,最后还是不行,然后我就升级啦kafka的版本,所有地址用
KAFKA_LISTENERS: PLAINTEXT://192.111.1.1:9192
但是配置后,kafka启动失败 博主能不能给看下 让kafka搞得没脾气了
ip不匹配,获取当前节点的ip
hostname -i
是地址不可用,
192.111.1.1:9192
,我怀疑是容器内的地址和你传入的不匹配。(docker启动的时候应该是可以指定ip的吧,否则ip都是随机生成的,我看你们都没有指定ip。)你可以参考下这篇文章:https://www.orchome.com/8183
你的答案