1、官网下载安装包:
安装包:kafka_2.11-1.1.0.tgz
2、解压安装:
tar -zxvf kafka_2.11-1.1.0.tgz -C ~/apps/
3、进入安装目录:cd apps/kafka_2.11-1.1.0/
4、开启kafka之前要开启zookeeper (如果是HA,则所有的节点都要开启zookeeper,命令:zkServer.sh start),
然后开启kafka命令(进入kafka安装目录):bin
/kafka-server-start
.sh config
/server
.properties
5、(复制一节点2 ) 查看是否开启kafka:
6、创建topics 创建一个名为“test”的主题
bin
/kafka-topics
.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic
test
7、查看主题:bin
/kafka-topics
.sh --list --zookeeper localhost:2181
8、启动生产者:bin
/kafka-console-producer
.sh --broker-list localhost:9092 --topic
test
并依次输入以下(测试)内容:this is am message
this is another message
9、(复制一节点3 )启动消费者:
bin
/kafka-console-consumer
.sh --bootstrap-server localhost:9092 --topic
test
--from-beginning
可以看到:
以上代表安装成功kafka