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.
Use the following command to find the Java JDK installation directory.
This command output should show you the Java installation directory.
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
Here is the java.sh file content.
Reboot the computer.
Use the following command to verify if the JAVA_HOME variable was created.
Here is the command output:
Use the following command to test the Java installation.
Here is the command output:
Install the Zookeeperd package.
Verify if the Zookeeperd service is running.
Here is the command output:
Configure Zookeeperd to start automatically during boot time.
Download the Apache Kafka package.
Install the Apache Kafka server.
Now, you need to create an environment variable named KAFKA_HOME.
Let’s create a file to automate the required environment variables configuration
Here is the kafka.sh file content.
Reboot the computer.
Use the following command to verify if the KAFKA_HOME variable was created.
Here is the command output:
Create a symbolic link to make it easier to find the Kafka configuration file.
Start the Apache Kafka service.
Here is a sample of the information that should be displayed:
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.
Use the following command to send a message to the Topic named TopicTest using the Kafka Producer API.
Enter the desired message.
Keep this terminal open.
On another Linux terminal, use the following command to fetch the messages from the Topic named TopicTest using the Kafka Consumer API.
Congratulations! You are able to send and receive messages from an Apache Kafka server.