Step 1: 启动服务器
首先启动zookeeper
> bin/zookeeper-server-start.sh config/zookeeper.properties
接着启动kafka服务器
> bin/kafka-server-start.sh config/server.properties
Step 2: 创建 一个 topic
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看topic
> bin/kafka-topics.sh --list --zookeeper localhost:2181
Step 3: Send some messages
> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
This is a message
This is another message
Step 4: 启动一个客户端(消费者)
> bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning