kafka的安装和配置

时间:2021-06-14 08:23:59
首先下载kafka安装包
tar -zxvf kafka安装包
cd config
vim server.properties

A.将zookeeper.connect=zookeeper的ip:2181 这一步也可以不做

启动kafka
如果A做了就不做这个B

B. bin/zookeeper-server-start.sh config/zookeepe!

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

![这里写图片描述](http://img.blog.csdn.net/20171005162022929?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdzMwNDU4NzI4MTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)


创建topic
bin/kafka-topics.sh --create --zookeeper zookeeper所在的ip:2181 --replication-factor 1 --partitions 1 --topic test

查看主题
bin/kafak-topics.sh --list --zookeeper zookeeper所在的ip:2181

![这里写图片描述](http://img.blog.csdn.net/20171005162038583?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdzMwNDU4NzI4MTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)

启动producer
bin/kafka-console-producer.sh --broker-list localhost:2181 --topic test

![这里写图片描述](http://img.blog.csdn.net/20171005162050396?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdzMwNDU4NzI4MTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)

启动consumer
bin/kafka-console-consumer.sh --zookeeper zookeeper所在的ip:2181 --topic test

![这里写图片描述](http://img.blog.csdn.net/20171005162059609?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdzMwNDU4NzI4MTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)