本文共 1158 字,大约阅读时间需要 3 分钟。
环境: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)创建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
bin/kafka-console-producer.sh --broker-list hadoop:9092 --topic dayu
[root@hadoop kafka_2.11-0.10.2.1]# bin/kafka-console-consumer.sh --bootstrap-server hadoo9092 --topic dayusdf sdf sdf
转载地址:http://ecygi.baihongyu.com/