安装
kafka依赖Java,因此要确保先安装好java
// mac 环境使用brew直接安装kafka
brew install kafka
// 卸载
brew uninstall kafka
启动
// 启动
brew services start kafka
brew services start zookeeper
// 重启
brew services restart kafka
brew services restart zookeeper
创建主题
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
删除主题
kafka-topics --delete --zookeeper localhost:2181 --topic 【topic name】
查看主题
kafka-topics --list --zookeeper localhost:2181
生产消息
kafka-console-producer --broker-list localhost:9092 --topic test
消费消息
kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning