创建语法
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topic-name
获取kafka列表
bin/kafka-topics.sh --list --zookeeper localhost:2181
启动生产者以发送消息
语法
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic topic-name
启动消费者以接收消息
与生产者类似,在 config / consumer.proper-ties 文件中指定了缺省使用者属性。 打开一个新终端并键入以下消息消息语法。
语法
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --bootstrap-server localhost:9092 -topic topic-name
--from-beginning