kafka学习笔记

一、mac安装kafka:brew install kafkabootstrap

二、启动zookeeper:zookeeper-server-start /usr/local/etc/kafka/zookeeper.propertiesserver

三、启动kafka:kafka-server-start /usr/local/etc/kafka/server.properties  (kafka-server-start须要设置环境变量才能直接使用,若是报错,先执行kafka-server-stop /usr/local/etc/kafka/server.properties便可)kafka

四、建立topic:kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic kafka-topicit

五、查看topic列表:kafka-topics --list --zookeeper localhost:2181io

六、生产者命令使用:kafka-console-producer --broker-list localhost:9092 --topic kafka-topicconsole

七、消费者命令使用:kafka-console-consumer --bootstrap-server localhost:9092 --topic kafka-topic --from-beginning(执行成功后,生产者产生的消息都能在消费者这里出现了)变量

相关文章
相关标签/搜索