- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
Creating a Kafka Cluster with Confluent
With this hands-on lab, we will have the opportunity to install and configure a three-broker cluster using Confluent Community. We will start with three regular Ubuntu servers and build a working Kafka cluster. Kafka is a powerful tool for messaging and data stream processing. On top of this, Confluent offers additional features and immensely simplifies some aspects of the installation process for Kafka.
Lab Info
Table of Contents
-
Challenge
Install the Confluent Community Package on the Broker Nodes
- On all three nodes, add the GNU Privacy Guard (GPG) key plus package repository, and then install Confluent Community, plus Java. The format should look like this:
wget -qO - https://packages.confluent.io/deb/5.2/archive.key | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/5.2 stable main" sudo apt-get update && sudo apt-get install -y openjdk-8-jre-headless confluent-community-2.12 -
Challenge
Configure Zookeeper
- On all three nodes, edit the
hostsfile:
sudo vi /etc/hosts- Add the following entries to the
hostsfile:
10.0.1.101 zoo1 10.0.1.102 zoo2 10.0.1.103 zoo3- Edit the
zookeeperconfig file:
sudo vi /etc/kafka/zookeeper.properties- Delete the contents of the config file and add the following:
tickTime=2000 dataDir=/var/lib/zookeeper/ clientPort=2181 initLimit=5 syncLimit=2 server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 autopurge.snapRetainCount=3 autopurge.purgeInterval=24- Set up the
zookeeperID for each server:
sudo vi /var/lib/zookeeper/myid- On each server, set the contents of
/var/lib/zookeeper/myidto the server's ID. On Node 1, enter1, on Node 2, enter2, and lastly on Node 3, enter3:
<server id 1, 2, or 3> - On all three nodes, edit the
-
Challenge
Configure Kafka
- Edit the
kafkaconfig file:
sudo vi /etc/kafka/server.properties-
Edit the
broker.idandzookeeper.connectin the config file. Set the broker ID to the appropriate ID for each server (1on Node 1,2on Node 2, and so on). -
Set
zookeeper.connecttozoo1:2181:
broker.id=<server id 1, 2, or 3> ... zookeeper.connect=zoo1:2181 - Edit the
-
Challenge
Start Zookeeper and Kafka
- Start and enable the Zookeeper and Kafka services:
sudo systemctl start confluent-zookeeper sudo systemctl enable confluent-zookeeper sudo systemctl start confluent-kafka sudo systemctl enable confluent-kafka- Both services should be
active (running)on all three servers. Check the services to make sure they are running:
sudo systemctl status confluent*- We can test our cluster by listing the current topics:
kafka-topics --list --bootstrap-server localhost:9092The output should look like this:
_confluent.support.metrics
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.