问题:
1.java.net.UnknownHostException
修改/etc/hosts文件指定ip
127.0.0.1 bogon
2.创建topic报错replication factor: 2 larger than available brokers: 0
--zookeeper localhost:2181/kafka需要指定kafka目录
3.replication factor: 2 larger than available brokers: 1
因为单机只启动一个broker,所以,factor不能超过broker数目
启动:
工具测试是否正常启动
启动生产者
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
启动消费者
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
--from-beginning(start with the earliest message present in the log rather than the latest message 从最早消息开始读取)
可以把--from-beginning去掉再尝试效果