Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

Not able to read messages from kafka consumer in kafka cluster setup

I have created two kafka brokers in a kafka cluster. When one broker is down I am not able to get any data to kafka consumer. I am using this command to read messages from consumer:

bin/kafka-console-consumer.sh --topic test_kafka_cluster 
    --bootstrap-server 127.0.0.1:9092,127.0.0.2:9092 --from-beginning
question from:https://stackoverflow.com/questions/65839586/not-able-to-read-messages-from-kafka-consumer-in-kafka-cluster-setup

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here as per your console consumer configuration, IP address used here are 127.0.0.1 and 127.0.0.2 and two bootstrap servers are configured as 9092.

Verify both the ip's are reachable

bin/kafka-console-consumer.sh --topic test_kafka_cluster 
--bootstrap-server 127.0.0.1:9092,127.0.0.2:9092 --from-beginning

Ideally when we run tow kafka broker instance it will be running in two different ports.

Presuming Kafka is running in local Eg: localhost:9092 localhost:9093

Kafka instances running on two different host: Eg: 127.0.0.3:9092, 127.0.0.2:9092

If Kafka is running on docker/docker toolbox:

Console consumer on Docker toolbox:

docker exec <container-name> kafka-console-consumer --bootstrap-server 192.168.99.100:9093 --topic <topic-name> --from-beginning

Console consumer on Docker:

docker exec <container-name> kafka-console-consumer --bootstrap-server localhost:9093 localhost 9092 --topic <topic-name> --from-beginning

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...