基本命令
创建topic
./bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic codesheep
查看已有的topic
./bin/kafka-topics.sh --list --bootstrap-server localhost:9092
创建生产者
./bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic codesheep
创建消费者
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic codesheep
查看topic里的数据出现问题
zookeeper is not a recognized option
这是因为–zookeeper是一个过时的方法,此时,才知道原来在最新的版本中,这种启动方式已经被删除了。
新版本的启动方法
./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic codesheep --from-beginning