How to install Apache Kafka on Ubuntu

To install Apache Kafka on Ubuntu, following are the prerequisites required :

  1. Java
  2. Zookeeper

And finally, we shall setup Apache Kafka and run it on the Ubuntu machine.

Install Apache Kafka on Ubuntu - Setup Apache Kafka on Ubuntu - Apache Kafka Tutorial - www.tutorialkart.com

Install Apache Kafka in Ubuntu

Install Java

Open a terminal and run the following command :

kafkauser@tutorialkart:~$ sudo apt-get install default-jdk

To verify the installation of java, run the following command in the terminal :

kafkauser@tutorialkart:~$ java -version

The output should show the version of java installed, similar to below verbose :

Zookeeper

There is no need to explicitly install Zookeeper, as it comes included with Apache Kafka.

Setup Apache Kafka – Install Apache Kafka on Ubuntu

Download the latest Apache Kafka from https://kafka.apache.org/downloads under Binary downloads.

Extract the .tgz file.

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.

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

$ 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.

$ 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 Ubuntu and start Kafka along with Zookeeper.