Would you like to learn how to do a Apache Kafka installation on Ubuntu Linux? In this tutorial, we are going to show you how to download and install Apache Kafka on a computer running Ubuntu Linux.

• Ubuntu 18.04
• Ubuntu 19.04
• Ubuntu 19.10
• Apache Kafka 2.12-2.3.1
• Openjdk version 11.0.4

Hardware List:

The following section presents the list of equipment used to create this Apache Kafka tutorial.

Every piece of hardware listed above can be found at Amazon website.

Apache Kafka Related Tutorial:

On this page, we offer quick access to a list of tutorials related to Apache Kafka.

Tutorial Apache Kafka - Installation on Ubuntu Linux

Install the Java JDK package.

Copy to Clipboard

Use the following command to find the Java JDK installation directory.

Copy to Clipboard

This command output should show you the Java installation directory.

Copy to Clipboard

In our example, our Java JDK is installed under the folder: /usr/lib/jvm/java-11-openjdk-amd64

Now, you need to create an environment variable named JAVA_HOME.

Let’s create a file to automate the required environment variables configuration

Copy to Clipboard

Here is the java.sh file content.

Copy to Clipboard

Reboot the computer.

Copy to Clipboard

Use the following command to verify if the JAVA_HOME variable was created.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Use the following command to test the Java installation.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Install the Zookeeperd package.

Copy to Clipboard

Verify if the Zookeeperd service is running.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Configure Zookeeperd to start automatically during boot time.

Copy to Clipboard

Download the Apache Kafka package.

Copy to Clipboard

Install the Apache Kafka server.

Copy to Clipboard

Now, you need to create an environment variable named KAFKA_HOME.

Let’s create a file to automate the required environment variables configuration

Copy to Clipboard

Here is the kafka.sh file content.

Copy to Clipboard

Reboot the computer.

Copy to Clipboard

Use the following command to verify if the KAFKA_HOME variable was created.

Copy to Clipboard

Here is the command output:

Copy to Clipboard

Create a symbolic link to make it easier to find the Kafka configuration file.

Copy to Clipboard

Start the Apache Kafka service.

Copy to Clipboard

Here is a sample of the information that should be displayed:

Copy to Clipboard

Congratulations! You have finished the Apache Kafka installation on Ubuntu Linux.

Apache Kafka - Command Examples

Use the following command to create a topic named TopicTest on your Apache Kafka server.

Copy to Clipboard

Use the following command to send a message to the Topic named TopicTest  using the Kafka Producer API.

Copy to Clipboard

Enter the desired message.

Keep this terminal open.

Copy to Clipboard

On another Linux terminal, use the following command to fetch the messages from the Topic named TopicTest using the Kafka Consumer API.

Copy to Clipboard

Congratulations! You are able to send and receive messages from an Apache Kafka server.