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/bin
oropt/homebrew/bin
-
Kafka configurations will be in
/usr/local/etc/kafka
oropt/homebrew/etc/kafka
-
Zookeeper configuration will be in
/usr/local/etc/zookeeper
oropt/homebrew/etc/zookeeper
-
The
log.dirs
config (the location for Kafka data) will be set to/usr/local/var/lib/kafka-logs
oropt/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.cfg
file at/usr/local/etc/zookeeper/zoo.cfg
and set the following to your heart’s desiredataDir=/your/path/to/data/zookeeper
-
start Zookeeper using the update
zoo.cfg
file as shown above -
you can also make a copy of the
zoo.cfg
file anywhere in your computer and edit that file instead, and reference it in the Zookeeper start command shown above
-
edit the
server.properties
file at/usr/local/etc/kafka/server.properties
and set the following to your heart’s desirelog.dirs=/your/path/to/data/kafka
-
start Zookeeper using the update
server.properties
file as shown above -
you can also make a copy of the
server.properties
file anywhere in your computer and edit that file instead, and reference it in the Zookeeper start command shown above.