Building a Kafka Cluster on Mac

Install Java and Kafka

brew cask install java
brew services list
brew install zookeeper

brew install kafka

Starting Zookeeper and Kafka

vim /usr/local/etc/kafka/server.properties
vim /usr/local/etc/kafka/zookeeper.properties
#listeners=PLAINTEXT://:9092
listeners=PLAINTEXT://localhost:9092
  • add listeners listeners=PLAINTEXT://localhost:9092

Running Kafka Locally

ZooKeeper & Kafka Server

zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
kafka-server-start /usr/local/etc/kafka/server.properties

Service (zookeeper & Kafka) start on Background

brew services start zookeeper
brew services start kafka

Service (zookeeper & Kafka) stop on Background

brew services stop kafka
brew services stop zookeeper
zkServer stop

Service (zookeeper & Kafka) restart on Background

brew services restart kafka
brew services restart zookeeper

If you have this error

kafka.common.InconsistentClusterIdException: The Cluster ID 7E5Ic575SiebC-8oMEtwcA doesn't match stored clusterId Some(OrjJ8z1HTPGtTGfH96btuQ) in meta.properties. The broker is trying to join the wrong cluster. Configured zookeeper.connect may be wrong.
	at kafka.server.KafkaServer.startup(KafkaServer.scala:252)
	at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:44)
	at kafka.Kafka$.main(Kafka.scala:82)
	at kafka.Kafka.main(Kafka.scala)
  • Stop kafka service: brew services stop kafka
  • open kafka server.properties file: vim /usr/local/etc/kafka/server.properties
  • find value of log.dirs in this file. For me, it is /usr/local/var/lib/kafka-logs
  • delete path-to-log.dirs/meta.properties file
  • start kafka service brew services start kafka

Leave a Reply

Your email address will not be published.

ANOTE.DEV