How to install Kafka with Homebrew?
- Install Homebrew
-
Run
brew install kafka - Start Zookeeper using the CLI
- Start Kafka using the CLI in another terminal
Control vs HomebrewFor more control over your Kafka installation and different binary versions, we prefer using the method above instead of Homebrew. Nonetheless, here are the steps to install Kafka using Homebrew
/usr/local/Cellar. Macs with Apple silicon will install Kafka under opt/homebrew/Cellar. In both cases, the files will be linked into other directories:
-
Binaries and scripts will be in
/usr/local/binoropt/homebrew/bin -
Kafka configurations will be in
/usr/local/etc/kafkaoropt/homebrew/etc/kafka -
Zookeeper configuration will be in
/usr/local/etc/zookeeperoropt/homebrew/etc/zookeeper -
The
log.dirsconfig (the location for Kafka data) will be set to/usr/local/var/lib/kafka-logsoropt/homebrew/var/lib/kafka-logs
Macs with Apple ChipsRemember, if you have a Mac with an M chip from Apple, you will need to replace
/usr/local/ with /opt/homebrew/. The instructions are identical otherwise.Start Zookeeper
Apache Kafka depends on Zookeeper for cluster management. Hence, prior to starting Kafka, Zookeeper has to be started. There is no need to explicitly install Zookeeper, as it comes included with Apache Kafka. After installation is complete, you can start Zookeeper using the following command
Start Apache Kafka
Open another Terminal window and run the following command from the root of Apache Kafka to start Apache Kafka.
Optional: changing the Kafka and Zookeeper data storage directory when using Homebrew
For Zookeeper:-
edit the
zoo.cfgfile at/usr/local/etc/zookeeper/zoo.cfgand set the following to your heart’s desiredataDir=/your/path/to/data/zookeeper -
start Zookeeper using the update
zoo.cfgfile as shown above -
you can also make a copy of the
zoo.cfgfile anywhere in your computer and edit that file instead, and reference it in the Zookeeper start command shown above
-
edit the
server.propertiesfile at/usr/local/etc/kafka/server.propertiesand set the following to your heart’s desirelog.dirs=/your/path/to/data/kafka -
start Zookeeper using the update
server.propertiesfile as shown above -
you can also make a copy of the
server.propertiesfile anywhere in your computer and edit that file instead, and reference it in the Zookeeper start command shown above.