【Docker】使用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

[[email protected] 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管理界面
【Docker】使用docker 搭建Kafka,使用命令创建生产者和消费者报错???

回答

以上是 【Docker】使用docker 搭建Kafka,使用命令创建生产者和消费者报错??? 的全部内容, 来源链接: utcz.com/a/81837.html

回到顶部