- 安装Java
sudo apt-get install openjdk-8-jdk - 新版的Kafka已经集成了zookeeper,所以不用单独安装zookeeper
有需要可以查看安装zookeeper - Kafka官网下载Kafka
tar -zxvf kafka_2.11-1.0.0.tgz
- 进入kafka解压目录,修改kafka-server 的配置文件
vim config/server.properties
如下
broker.id=1
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://ubuntu的IP地址:9092
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test