安装 Kafka
下载地址
Kafka Download解压步骤
tar -zxvf kafka_2.12-2.1.0.tgz
cd kafka_2.12-2.1.0
- 修改 kafka-server 配置
kafka_2.12-2.1.0/config/server.properties
broker.id=1
log.dir=/kafka/logs
使用 Kafka
功能 | 启动命令 | 备注 |
---|---|---|
启动 ZK | bin/zookeeper-server-start.sh -daemon config/zookeeper.properties | Kafka 安装包自带 ZK,可以单节点启动 |
启动 Kafka 服务器 | bin/kafka-server-start.sh config/server.properties | |
创建 Topic(test) | bin/kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test | |
Topic 列表 | bin/kafka-topics.sh –list –zookeeper localhost:2181 | |
启动 Producer | bin/kafka-console-producer.sh –broker-list localhost:9092 –topic test | |
启动 Consumer | bin/kafka-console-consumer.sh –bootstrap-server localhost:9092 –topic test –from-beginning | |
Topic 相关信息(test) | bin/kafka-topics.sh –describe –zookeeper localhost:2181 –topic test |