How to install Apache Kafka on Mac with Homebrew
Learn how to start Apache Kafka on Mac OS with Homebrew (brew)
Install Homebrew
Run
brew install kafka
Start Zookeeper using the CLI
Start Kafka using the CLI in another terminal
For 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
If you have already installed Homebrew for Mac OS, you can use it to install Kafka in one step. This will ensure that you have Java installed first, and it will then install Apache Kafka.
If you have not yet installed Homebrew, do that first by following the directions on the installation page.
Then you can install Kafka itself. The Homebrew package manager will ensure that you have all the dependencies installed first, including the necessary Java version:
Homebrew's default installation path will differ based on the chip: Macs using Intel will install Kafka under /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
Remember, 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.
Ensure to keep both terminal windows opened, otherwise you will shut down Kafka or Zookeeper.
Kafka is now started, congratulations!
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 aboveyou 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
For Kafka:
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 aboveyou 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.
Get a free Kafka cluster with Conduktor Platform
Conduktor Platform provides the easiest way to get started with Apache Kafka. Just sign up to our web app and you'll get a free managed Kafka cluster that you can use to learn and experiment. There is no trial period or constant pestering, just head to the signup page and get started