使用docker 搭建Kafka,使用命令创建生产者和消费者报错???
docker-compose.yml
version: '3.0'
services:
zookeeper:
image: wurstmeister/zookeeper
restart: always
hostname: zook
container_name: my_zook
ports:
- "2181:2181"
kafka01:
image: wurstmeister/kafka:2.12-2.4.0
restart: always
hostname: Kafka01
container_name: my_kafka01
ports:
- "19092:9092"
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.72.158:19092
KAFKA_ADVERTISED_HOST_NAME: 192.168.72.158
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- ./logs/kafka01:/kafka
kafka02:
image: wurstmeister/kafka:2.12-2.4.0
restart: always
hostname: Kafka02
container_name: my_kafka02
ports:
- "29092:9092"
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://192.168.72.158:29092
KAFKA_ADVERTISED_HOST_NAME: 192.168.72.158
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- ./logs/kafka02:/kafka
[root@localhost kafka-logs-Kafka]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40aa47400b5a wurstmeister/kafka:2.12-2.4.0 "start-kafka.sh" 21 hours ago Up 21 hours 0.0.0.0:29092->9092/tcp my_kafka02
4da1d152f50b wurstmeister/kafka:2.12-2.4.0 "start-kafka.sh" 21 hours ago Up 21 hours 0.0.0.0:19092->9092/tcp
创建生产者报错(在容器内 opt/kafka目录下执行)
bash-4.4# bin/kafka-console-producer.sh --broker-list 192.168.72.158:19092 --topic user
>[2020-03-15 03:28:42,371] WARN [Producer clientId=console-producer] Connection to node -1 (/192.168.72.158:19092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
Kafka管理界面
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论