How To Install Apache Kafka on CentOS 8

Install Apache Kafka on CentOS 8

In this tutorial we will show you how to install Apache Kafka on CentOS 8. For those of you who didn’t know, pache Kafka is a distributed message agent designed to deal with huge volumes of real time information effectively. Unlike traditional agents like ActiveMQ and RabbitMQ, Kafka functions as a bunch of one or more servers that makes it highly scalable and because of the distributed nature, it’s inbuilt fault-tolerance whilst providing greater throughput when compared to its counterparts.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Apache Kafka on a CentOS 8 server.

Install Apache Kafka on CentOS 8

Step 1. First let’s start by ensuring your system is up-to-date.

Step 2. Installing Java.

Apache Kafka requires Java to be installed on your server. You can install OpenJDK on your machine by executing the following command:

Verify the Java version by running the following command:

Step 3. Installing Apache Kafka on CentOS 8.

First, download and extract Kafka from Apache website. You can use wget to download Kafka:

Then extract the archive file:

Step 4. Setup Kafka Systemd Unit Files.

First, create systemd unit file for Zookeeper with below command:

Add below content:

Then, to create a Kafka systemd unit file using the following command:

Add the below content:

Reload the systemd daemon to apply changes:

Step 5. Start Kafka Server.

Kafka required ZooKeeper so first, start a ZooKeeper server on your system:

Next start the Kafka server and view the running status:

Step 6. Creating Topics in Apache Kafka.

The “producer” is the process responsible for put data into our Kafka. The Kafka comes with a command line client that will take input from a file or from standard input and send it out as messages to the Kafka cluster:

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:

Step 7. Apache Kafka Producer and Consumer.

Let’s run the producer and then type a few messages into the console to send to the server:

Kafka also has a command line consumer to read data from Kafka cluster and display messages to standard output:

Congratulation’s! You have successfully installed Apache Kafka. Thanks for using this tutorial for installing Apache Kafka in CentOS 8 system. For additional help or useful information, we recommend you to check the official Apache Kafka website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!