How To Install Apache Kafka on Ubuntu 16.04/18.04/20.04

Apache Kafka is a mainstream disseminated message agent intended to deal with huge volumes of ongoing information productively. A Kafka bunch isn’t just exceptionally adaptable and blame tolerant, however it likewise has an a lot higher throughput contrasted with other message representatives, for example, ActiveMQ and RabbitMQ. In spite of the fact that it is commonly utilized as a bar/sub informing framework, a great deal of associations likewise use it for log conglomeration since it offers tireless capacity for distributed messages.

Step 1:- Update apt repository and install Java by following the commands.

sudo -i

apt-get update && apt-get install default-jdk -y

After installation of Java, Verify it by using the given commands.

java --version

You should get the Java server details.

Step 2:- Install Zoopker by using the following commands.

apt-get install zookeeperd -y

By default Zookeeper listen on 2181 to vefity it use the given commands.

telnet localhost 2181

Step 3:- Create User for Kafka and Set the strong password by following the commands.

useradd kafka -m

passwd kafka

adduser kafka sudo

su kafka

Step 4:- Download the Apache Kafka Binaries and Extract it by following the given commands.

mkdir ~/kafka && cd ~/kafka


tar -xvzf kafka*.tgz --strip 1

Step 5:- Create a service for Apache kafka by using the steps.

sudo nano /etc/systemd/system/kafka.service






ExecStart=/home/kafka/kafka/bin/ /home/kafka/kafka/config/



Save and Exit from nano editor.

Step 6:- Start the Apache Kafka Service

first need to relaod the daemon by following the commands.

sudo systemctl daemon-reload

To start the Apache Kafka service use the following commands.

sudo systemctl start kafka

To get the Apache Kafka services status use the following commands.

sudo systemctl status kafka

Verify the Apache Kafka port number by using telnet.

telnet localhost 9092

Step 7:- Testing Apache Kafka

You need to create a Topic by using the commands.

~/kafka/bin/ --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic TechBeginner

After Created the Topic TechBeginner, You need to print “Hello World” on TechBeginner Topic, Use the following commands for this.

echo "Hello, World" | ~/kafka/bin/ --broker-list localhost:9092 --topic TechBeginner > /dev/null

Open the new Terminal to become a consumer of TechBeginner Topic and recived the messages from Publisher.

~/kafka/bin/ --bootstrap-server localhost:9092 --topic TechBeginner --from-beginning

How To Install Apache Kafka on Ubuntu 16.04/18.04/20.04

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top