Apache Kafka is a distributed event streaming platform capable of handling trillions of events a day. It is widely used for building real-time data pipelines and streaming applications. In this guide, we will walk you through the installation of Apache Kafka on Ubuntu 22.04. Whether you are deploying it on a local server or using a Windows VPS UK, this tutorial provides all the necessary steps.

Step 1: Update Your System

Before installing Apache Kafka, ensure your system is up to date. Run the following commands:

sudo apt update && sudo apt upgrade -y

Keeping your system updated is crucial for security and performance, whether you're setting it up locally or on a VPS Windows Servers platform.

Step 2: Install Java

Kafka requires Java to run. Install OpenJDK 11 using the following command:

sudo apt install openjdk-11-jdk -y

After installation, verify the Java installation:

java -version

Step 3: Download and Install Apache Kafka

Navigate to the /opt directory and download the latest version of Apache Kafka:


cd /opt
sudo wget https://downloads.apache.org/kafka/3.4.0/kafka_2.13-3.4.0.tgz
            

Extract the downloaded file:

sudo tar -xvzf kafka_2.13-3.4.0.tgz

Rename the extracted folder for easier access:

sudo mv kafka_2.13-3.4.0 kafka

Step 4: Start Zookeeper and Kafka Server

Kafka uses Zookeeper to manage distributed brokers. Start the Zookeeper server with the following command:

sudo /opt/kafka/bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties

Open a new terminal session and start the Kafka server:

sudo /opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties

Step 5: Create a Kafka Topic

To create a topic in Kafka, use the following command:

sudo /opt/kafka/bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1

You can verify that the topic was created successfully with the following command:

sudo /opt/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092

Step 6: Send Messages to the Kafka Topic

Open a new terminal session and start a producer to send messages to the topic:

sudo /opt/kafka/bin/kafka-console-producer.sh --topic test --bootstrap-server localhost:9092

Type messages and press Enter to send them to the topic.

Step 7: Consume Messages from the Kafka Topic

Open another terminal session and start a consumer to read messages from the topic:

sudo /opt/kafka/bin/kafka-console-consumer.sh --topic test --from-beginning --bootstrap-server localhost:9092

You should see the messages that were sent to the topic.

You have successfully installed Apache Kafka on your Ubuntu 22.04 server, enabling you to manage your event streaming applications effectively. For reliable and scalable hosting solutions, consider using Windows VPS UK. They offer a variety of hosting options, including windows virtual private servers, windows vps hosting, and windows virtual dedicated server hosting. Whether you're looking for windows vps italy or uk vps windows solutions, their hosting services provide the performance and flexibility needed to support your Kafka deployment.

Was this answer helpful? 0 Users Found This Useful (0 Votes)