How to Install Apache Kafka on Debian 10

Install Apache Kafka on Debian 10

In this article, we will have explained the necessary steps to install and setup Apache Kafka on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Apache Kafka is an open-source stream-processing software platform developed by the Apache Software Foundation, written in Scala and Java. The project aims to provide a unified, high-throughput, low-latency platform for real-time handling data feeds. Kafka is highly valuable for enterprise infrastructures to process streaming data.

Install Apache Kafka on Debian

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

Step 2. Install Java.

Apache Kafka is a Java application, so the first step is to install Java. Run following commands to install Java:

Verify the Java installation:

Step 3. Creating a User for Kafka.

To create a user, type the commands below while logged in as a non-root sudo user:

Next, we need to add the kafka user to the sudo group for it to have sudo privileges that will be required to install Kafka’s dependencies:

Step 4. Install Apache Kafka on Debian.

Download the Apache Kafka binary files from its official download website:

Then, extract the archive file:

Step 5. Configure the Kafka Server.

It is time to configure Apache Kafka. By default, we are not allowed to delete topics, categories or groups in which messages can be posted. To change this behavior, we need to edit the default configuration:

Add the following line to the bottom of the file to allow us to delete Kafka topics:

Step 6. Setup Kafka Systemd Unit Files.

Create systemd unit files for the Zookeeper and Kafka service:

Now, let’s create a system unit file for kafka at the filepath /etc/systemd/system/kafka.service:

Reload the systemd daemon to apply new changes:

Next, start Kafka with the command below:

Step 7. Testing the Installation.

Kafka provides multiple pre-build shell script to work on it. First, create a topic named “testTopic” with a single partition with single replica:

You can create multiple topics by running the same command as above. After that, you can see the created topics on Kafka by the running below command:

Send Messages to Kafka:

Using Kafka Consumer:

Congratulation, you have learned how to install and configure Apache Kafka on Debian Buster. If you have any question, please leave a comment below.