一、问题描述
环境:kafka_2.11-0.10.2.1
Kafka开启生产者和消费者,当生产者发出消息的时候,消费者报错,而之前采用kafka_2.10-0.8.2.1运行该消费者的时候有没有问题:
root@hadoop kafka_2.11-0.10.2.1]# bin/kafka-console-consumer.sh --topic dayu --zookeeper hadoop:2181/kafka10_01
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
[2020-03-01 16:55:19,994] WARN [ConsumerFetcherThread-console-consumer-11986_hadoop-1583052858368-33af0818-0-2], Error in fetch kafka.consumer.ConsumerFetcherThread$FetchRequest@66bc1f66 (kafka.consumer.ConsumerFetcherThread)
二、问题原因
kafka_2.11-0.10.2.1升级了消费者命令,采用bootstrap-server参数,而不是之前的zookeeper参数。其实报错里面已经很清楚了。
三、解决办法
1.准备
(1)创建topic
bin/kafka-topics.sh --create --topic dayu --zookeeper hadoop:2181/kafka10_01 --partitions 1 --replication-factor 1
(2)查看topic
bin/kafka-topics.sh --list --zookeeper hadoop:2181/kafka10_01
2.开启producer
bin/kafka-console-producer.sh --broker-list hadoop:9092 --topic dayu
3.开启消费者,同时从生产者输入sdf sdf sdf
[root@hadoop kafka_2.11-0.10.2.1]# bin/kafka-console-consumer.sh --bootstrap-server hadoo9092 --topic dayu
sdf sdf sdf
来源:CSDN
作者:RayBreslin
链接:https://blog.csdn.net/u010886217/article/details/104595765