Learn Apache Kafka

Installing Kafka On Linux

Install and Setup Kafka on Linux: -

Prerequisites:

JDK 8 and above

 

Steps to Install Kafka on Linux

Step1: Download Apache kafka latest version

$cd /opt

$wget https://mirrors.estointernet.in/apache/kafka/2.8.0/kafka_2.13-2.8.0.tgz

Once your download is complete, unzip the file’s contents using tar, a file archiving tool and rename the folder to kafka

 

Step2: Extract tar file and rename

$sudo tar -xzf kafka_2.13-2.8.0.tgz

$sudo mv kafka_2.13-2.8.0 kafka

 

Step3: Set Kafka home and PATH environment variable on .bashrc or .profile file.

$nano ~/.bashrc

....

export KAFKA_HOME=/opt/kafka

PATH=$PATH:$KAFKA_HOME/bin

....

Save and Quit

 

Step4: Now reload the environment variables to the opened session by running below command.

$source ~/.bashrc

 

In case if you have added path to .profile file then restart your session by logging out and logging in again.

 

Step5: Start Zookeeper

ZooKeeper is a high-performance coordination service for distributed applications and Kafka uses ZooKeeper to store the metadata information of the cluster. Kafka comes with the Zookeeper built-in, all we need is to start the service with default configuration.

$zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties

 

Step6: Start Kafka Broker

A Kafka cluster consists of one or more brokers (Kafka servers) and broker organizes messages to respective topics and persists all the Kafka messages in a topic log file for 7 days. Depends on your replication factor of the topic, the messages are replicated to multiple brokers.

Open another ubuntu session/terminal and start Kafka server with default configuration.

$kafka-server-start.sh /opt/kafka/config/server.properties