Creating a Kafka Cluster with Confluent

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

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.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install the Confluent Community Package on the Broker Nodes
  1. 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 - | sudo apt-key add -
    sudo add-apt-repository "deb [arch=amd64] stable main"
    sudo apt-get update && sudo apt-get install -y openjdk-8-jre-headless confluent-community-2.12
Configure Zookeeper
  1. On all three nodes, edit the hosts file:

    sudo vi /etc/hosts
  2. Add the following entries to the hosts file: zoo1 zoo2 zoo3
  3. Edit the zookeeper config file:

    sudo vi /etc/kafka/
  4. Delete the contents of the config file and add the following:

  5. Set up the zookeeper ID for each server:

    sudo vi /var/lib/zookeeper/myid
  6. On each server, set the contents of /var/lib/zookeeper/myid to the server’s ID. On Node 1, enter 1, on Node 2, enter 2, and lastly on Node 3, enter 3:

    <server id 1, 2, or 3>
Configure Kafka
  1. Edit the kafka config file:

    sudo vi /etc/kafka/
  2. Edit the and zookeeper.connect in the config file. Set the broker ID to the appropriate ID for each server (1 on Node 1, 2 on Node 2, and so on).

  3. Set zookeeper.connect to zoo1:2181:<server id 1, 2, or 3>
Start Zookeeper and Kafka
  1. 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
  2. Both services should be active (running) on all three servers. Check the services to make sure they are running:

    sudo systemctl status confluent*
  3. We can test our cluster by listing the current topics:

    kafka-topics --list --bootstrap-server localhost:9092

    The output should look like this:

Additional Resources

Your company is getting ready to start using Confluent for some of their projects. Your task is to set up a Confluent Kafka cluster for the other Developers to experiment with.

You have been given three servers. Install Confluent Community on these servers and configure them as a single cluster.

If you get stuck, feel free to check out the solution video, detailed instructions under each objective, or click the Guide tab above the video player. Good luck!

Note: if either the confluent-zookeeper or confluent-kafka service doesn't doesn't start on any of the nodes, wait a moment and try to restart the service(s).

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?