Introduction
Apache Kafka is messaging engine that sends messages from producer to consumer, which is widely used in BigData projects. It is an open-source platform to stores real-time data streaming.
This article will explain how to install Apache Kafka on CentOS 7.
Prerequisites
- A non-root user with
sudoprivileges. - OpenJDK is installed on your server.
Install OpenJDK Runtime
-
First, you need to install Java on your system to run Apache Kafka.
# sudo yum -y install java-1.8.0-openjdk
- verify the Java-installed version.
# java -version
Download and install Apache Kafka
-
Install "wget" package.
# sudo yum -y install wget -
Download the stable version of Apache Kafka from the official website.
# wget https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz -
Unzip the downloaded package and move the file to
optdirectory.# tar -xzf kafka_2.13-3.4.0.tgz
#sudo mv kafka_2.13-3.4.0 /opt
Start and test Apache Kafka
- Go to the Kafka directory.
# cd /opt/kafka_2.13-3.4.0 - Start the Zookeeper, which comes built-in with the Kafka package.
# bin/zookeeper-server-start.sh -daemon config/zookeeper.properties -
Start the Kafka server with its default properties.
# bin/kafka-server-start.sh -daemon config/server.properties -
Create a sample topic using the following command.
# bin/kafka-topics.sh --create --topic idrive-compute --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 -
You can view your topics with the following command.
# bin/kafka-topics.sh --list --bootstrap-server localhost:9092