【JAVA】kafka

作者: Y了个J | 来源:发表于2018-06-08 21:26 被阅读19次

下载地址

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

    本文链接:https://www.haomeiwen.com/subject/kiqzsftx.html