To install Apache Kafka on Mac, Java is the only prerequisite. First we shall look into the installation steps of Java and then we shall setup Apache Kafka and run it on the Mac.

Install Java

  1. Open a browser and hit the url [http://www.oracle.com/technetwork/java/javase/downloads/index.html].
  2. Click on JDK, check “Accept License Agreement” and download .dmg file for installation on Mac.
  3. Double click on the downloaded file and proceed with the installation steps.
  4. You have successfully installed Java. You may delete the .dmg file, as memory is costly on Mac.

You may verify the installation of Java on Mac, by running the following command on a Terminal.

java -version
Java version on Mac

Install Apache Kafka on Mac

  1. Download the latest Apache Kafka from [https://kafka.apache.org/downloads] under Binary downloads. Download Kafka Webpage
  2. Click on any of the binary downloads, or choose a specific scala version if you have any dependency with scala in your development. Kafka Mirror Download Link
  3. Go with the recommended mirror site. Save Kafka Package
  4. Extract the contents. Navigate to root of Apache Kafka folder and open a Terminal. Or Open a Terminal and navigate to the root directory of Apache Kafka.

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.

From the root of Apache Kafka, run the following command to start Zookeeper :

~$sh bin/zookeeper-server-start.sh config/zookeeper.properties

The zookeeper should be started with a similar following trace in the output.

Start Apache Kafka Server

Open another Terminal and run the following command from the root of Apache Kafka to start Apache Kafka.

~$sh bin/kafka-server-start.sh config/server.properties

Following should be the end of trace stating that Kafka server is started.

Conclusion :

In this Apache Kafka Tutorial, we have successfully learnt to install Apache Kafka on Mac and start Kafka along with Zookeeper.