Kafka-2.2.0-安装
版本选择
目前阿里云最新版本是基于2.2.0版本开发
下载
# http://kafka.apache.org/downloads
# https://archive.apache.org/dist/kafka/2.2.0/kafka_2.12-2.2.0.tgz
tar xzf kafka_2.12-2.2.0.tgz
[ -d /usr/local/kafka ] || mv kafka_2.12-2.2.0 /usr/local/kafka
测试
# 创建topic
cd /usr/local/kafka
# 新版本用的bootstrap-server参数直接访问kafka的broker
# 老版本还是连接的zk
bin/kafka-topics.sh --create --zookeeper 127.0.0.1:2181 --replication-factor 1 --partitions 1 --topic test
# 查看topic
bin/kafka-topics.sh --list --zookeeper 127.0.0.1:2181
# 发送消息
> bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
This is a message
This is another message
# 接收消息
> bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
This is a message
This is another message
/usr/local/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
- 原文作者:zaza
- 原文链接:https://zazayaya.github.io/2020/03/11/kafka-install.html
- 说明:转载本站文章请标明出处,部分资源来源于网络,如有侵权请及时与我联系!