kafka本地单机模式配置

下载kafka:http://kafka.apache.org/downloads

配置config/server.properties

  启动kafka

lihudeMacBook-Pro:kafka_2.11-0.10.1.0 SunAndLi$ sh bin/kafka-server-start.sh config/server.properties

  新建一个topic

lihudeMacBook-Pro:kafka_2.11-0.10.1.0 SunAndLi$  bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic sun_test
查看topic是否成功
lihudeMacBook-Pro:kafka_2.11-0.10.1.0 SunAndLi$ bin/kafka-topics.sh --list --zookeeper localhost:2181

把KAFKA的生产者启动起来:
lihudeMacBook-Pro:kafka_2.11-0.10.1.0 SunAndLi$ bin/kafka-console-producer.sh --broker-list localhost:9092 --topic sun_test

另开一个终端,把消费者启动起来:
lihudeMacBook-Pro:kafka_2.11-0.10.1.0 SunAndLi$ bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic sun_test --from-beginning

ps:若需要挂到后台使用只需在代码后面添加&
原文地址:https://www.cnblogs.com/sunyaxue/p/6375119.html