How to Install Apache Kafka on Mac without Zookeeper? (KRaft mode)
Start and run Apache Kafka on Mac OS X without Zookeeper.
KRaft is in early access mode as of Apache Kafka 2.8 and should be used in development only. It is not suitable for production.
Install Java JDK version 11
Download Apache Kafka from https://kafka.apache.org/downloads under 'Binary Downloads'
Extract the contents on your Mac
Generate a cluster ID and format the storage using
Start Kafka using the binaries
Setup the $PATH environment variables for easy access to the Kafka binaries
To install Apache Kafka on Mac, Java 11 is the only prerequisite.
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.
Download the latest version of Apache Kafka from https://kafka.apache.org/downloads under Binary downloads.
2. 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
3. Download and extract the contents (double click in the Finder) to a directory of your choice, for example
4. 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
The first step is to generate a new ID for your cluster
This returns a UUID, for example
Next, format your storage directory (replace <uuid> by your UUID obtained above)
This will format the directory that is in the
log.dirs in the
config/kraft/server.properties file (by default
Now you can launch the broker itself in daemon mode by running this command.
Don’t close this terminal window as it will shutdown the broker.
Congratulations, the broker is now running on its own in KRaft mode!
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):
This ensures that you can now run the kafka commands without prefixing them.
After reloading your terminal, the following should work from any directory
You can read and learn more about the KRaft mode in Kafka here.