Mac local build Kafka

Time:2021-10-27

zookeeper

install

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

Modify dataDir in zook.cfg

start-up

cd bin
sh zkServer.sh start

kafka

install

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

Create topic

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

Start producer

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

Start consumer

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

docs