ubuntu上kafka的配置与使用(一)--单机kafka的配置

0.安装java环境

可以参考另一篇文章:https://www.cnblogs.com/codedoge/p/10101580.html

1.下载kafka(我下载的是2.11-2.1.0版本)

wget https://mirrors.cnnic.cn/apache/kafka/2.1.0/kafka_2.11-2.1.0.tgz

2.解压

tar -xzvf kafka_2.11-2.1.0.tgz

3.进入kafka的conf目录,修改相关配置文件

修改server.properties

4.启动zookeeper

./bin/zookeeper-server-start.sh ./config/zookeeper.properties

5.新开一个控制台,启动kafka

./bin/kafka-server-start.sh ./config/server.properties

6.新开一个控制台,创建topic

./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

7.查看topic列表

./bin/kafka-topics.sh --list --zookeeper localhost:2181

8.创建生产者

./bin/kafka-console-producer.sh --broker-list 10.1.3.xxx:9092 --topic test

9.新建窗口,创建消费者

#0.9版本之前:
./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
#0.9版本之后:
./bin/kafka-console-consumer.sh --bootstrap-server 10.1.3.xxx:9092 --topic test --from-beginning
原文地址:https://www.cnblogs.com/codedoge/p/10100953.html