mac本地安装kafka
brew install kafka
启动zookeeper、kafka
brew services start zookeeper
brew services start kafka
创建一个topic
kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 3 --topic test_1
创建一个生产者producer
kafka-console-producer --bootstrap-server localhost:9092 --topic test_1
创建一个消费者
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_1 --from-beginning
查看所有topic
kafka-topics --list -bootstrap-server localhost:9092
kafka-topics --list -bootstrap-server c02-01.kafka.k8s.local:9092,c02-02.kafka.k8s.local:9092,c02-03.kafka.k8s.local:9092
新建终端,向指定topic中发送消息中发送消息
kafka-console-producer --broker-list localhost:9092 --topic test
kafka-console-producer --broker-list c02-01.kafka.k8s.local:9092,c02-02.kafka.k8s.local:9092,c02-03.kafka.k8s.local:9092 --topic fota-event
新建终端,向指定topic接收消息
kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning
kafka-console-consumer --bootstrap-server c02-01.kafka.k8s.local:9092,c02-02.kafka.k8s.local:9092,c02-03.kafka.k8s.local:9092 --topic fota-event
停止kafka服务
./kafka-server-stop
停止zookeeper服务
./zookeeper-server-stop
groovy脚本/java程序发送kafka消息
--java--
--groovy--
标签:--,9092,kafka,topic,常用命令,k8s,local
From: https://www.cnblogs.com/xinxi-caas/p/17989393