1、下载
http://kafka.apache.org/downloads.html
Scala 2.12 - kafka_2.12-2.3.0.tgz (asc, sha512)
wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.3.0/kafka_2.12-2.3.0.tgz
2、启动
运行kafka需要使用Zookeeper,后台启动(推荐)
./zookeeper-server-start.sh ../config/zookeeper.properties 1>/dev/null 2>&1 &
启动kafka
后台启动kafka
./kafka-server-start.sh ../config/server.properties 1>/dev/null 2>&1 &
3、使用kafka
a、创建topic
test为test_Topic名称
#创建
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_Topic
#查询
./kafka-topics.sh --list --zookeeper localhost:2181 test_Topic
b、发送消息
./kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic
c、消费消息
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic --from-beginning
4、kafka其他命令
删除topic
./kafka-topics.sh --delete --zookeeper localhost:2181 --topic test_topic
topic 列表,上述删除命令执行后
./kafka-topics.sh --list --zookeeper localhost:2181