为方便测试,zookeeper(2181) 和kafka(9092) 启动端口都使用默认端口
下载和启动zookeeper:zookeeper ——— linux 部署 zookeeper_DGH2430284817的博客-CSDN博客
下载kafka:Kafka —— kafaka的安装和运行_DGH2430284817的博客-CSDN博客
kafka启动:进入kafka下载目录,指定配置文件server.properties 启动kafka
bin/kafka-server-start.sh config/server.properties
创建topic ,一个分区,topic名为testkane
bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic testkane --partitions 1 --replication-factor 1
查看是否创建成功
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
启动消费者,监听topic testkane
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testkane --from-beginning
启动生产者,发送消息到topic。testkane
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testkane
至此,测试完成,可以正常生产和消费消息



