How to install and run Kafka on Mac OS X
Start Kafka with ZooKeeperFor maximum compatibility purposes, we recommend to start Apache Kafka with ZooKeeper. If you would like to run Kafka without ZooKeeper, take a look at our KRaft mode guide.
How to install Kafka with ZooKeeper on Mac
- Install Java JDK version 11
- Download Apache Kafka from https://kafka.apache.org/downloads under ‘Binary Downloads’
- Extract the contents on your Mac
- Start ZooKeeper using the binaries
- Start Kafka using the binaries in another process
- Setup the $PATH environment variables for easy access to the Kafka binaries
Installing Java JDK 11
To install Apache Kafka on Mac, Java 11 is the only prerequisite.- Navigate to Amazon Corretto 11 download page (the Amazon distribution of OpenJDK 11) install amazon-corretto-11-x64-macos-jdk.pkg
- Double click on the downloaded file and proceed with the installation steps.
- You have successfully installed Java JDK 11. You may delete the .pkg file.

java -version
:
Install Apache Kafka on Mac OS X
- Download the latest version of Apache Kafka from https://kafka.apache.org/downloads under Binary downloads.

-
Click on any of the binary downloads (it is preferred to choose the most recent Scala version - example 2.13). For this illustration, we will assume version
2.13-3.0.0
. -
Download and extract the contents (double click in the Finder) to a directory of your choice, for example
~/kafka_2.13-3.0.0
. -
Navigate to the root of the Apache Kafka folder and open a Terminal. Or Open a Terminal and navigate to the root directory of Apache Kafka. For this example, we will assume that the Kafka download is expanded into the
~/kafka_2.13-3.0.0
directory.
JAVA_HOME
environment variable is set first, as instructed in the Install Java section, so that Java 11 is used when doing java -version
From the root of Apache Kafka, run the following command to start ZooKeeper:

You can use the
-daemon
flag to run ZooKeeper in daemon mode in the backgroundStart Apache Kafka
Open another Terminal window and run the following command from the root of Apache Kafka to start Apache Kafka.
Setup the $PATH environment variable
In order to easily access the Kafka binaries, you can edit your PATH variable by adding the following line (edit the content to your system) to your system run commands (for example~/.zshrc
if you use zshrc):
PATH="$PATH:/Users/stephanemaarek/kafka_2.13-3.0.0/bin"
This ensures that you can now run the kafka commands without prefixing them.
After reloading your terminal, the following should work from any directory
Optional: changing the Kafka and ZooKeeper data storage directory
For ZooKeeper:-
edit the
zookeeper.properties
file at~/kafka_2.13-3.0.0/config/zookeeper.properties
and set the following to your heart’s desiredataDir=/your/path/to/data/zookeeper
-
start ZooKeeper using the update
zookeeper.properties
file as shown above -
you can also make a copy of the
zookeeper.properties
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~/kafka_2.13-3.0.0/config/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