mac本地搭建kafka

zookeeper

安装

wget http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
tar zxvf zookeeper-3.4.6.tar.gz
cd zookeeper-3.4.6
cp -rf conf/zoo_sample.cfg conf/zoo.cfg
cd conf
vim zoo.cfg

修改zook.cfg里头的dataDir

启动

cd bin
sh zkServer.sh start

kafka

安装

wget http://apache.fayea.com/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz
tar -zxf kafka_2.10-0.8.2.1.tgz
cd kafka_2.10-0.8.2.1
sh bin/kafka-server-start.sh config/server.properties

创建topic

sh kafka-topics.sh --create --topic kafkatopic --replication-factor 1 --partitions 1 --zookeeper localhost:2181

启动producer

sh kafka-console-producer.sh --broker-list localhost:9092 --sync --topic kafkatopic

启动consumer

sh kafka-console-consumer.sh --zookeeper localhost:2181 --topic kafkatopic --from-beginning

docs

  • kafka+zookeeper环境配置(Mac 或者 linux环境)

你可能感兴趣的:(kafka)