Published on

mac搭建kafka

Authors
  • avatar
    Name
    gulu
    Twitter

安装

brew install kafka

安装的过程中会自动安装zk

启动zk

因为我之前单独安装过zk,所以直接启动之前的

zkServer start

启动kafka

brew services start kafka

查看所有的topic

kafka-topics --list --zookeeper localhost:2181

创建一个名为test1的topic

kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test1

使用生产一条消息

kafka-console-producer --broker-list localhost:9092 --topic test1

消费消息

kafka-console-consumer --bootstrap-server localhost:9092 --topic test1 --from-beginning