【JAVA】kafka

下载地址

https://www.apache.org/dyn/closer.cgi?path=/kafka/1.1.0/kafka_2.11-1.1.0.tgz

Quickstart

http://kafka.apache.org/quickstart

Start the server

> tar -xzf kafka_2.11-1.1.0.tgz
> cd kafka_2.11-1.1.0

kafka内置zookeeper服务,后台启动zookeeper
> nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &

后台启动kafka
> nohup ./bin/kafka-server-start.sh config/server.properties &

Create a topic

> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic hello
消费
> bin/kafka-topics.sh --list --zookeeper localhost:2181

Send some messages

> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic hello
This is a message
This is another message
启动另一个终端
> bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic hello --from-beginning
This is a message
This is another message

你可能感兴趣的:(【JAVA】kafka)