Building a Kafka Cluster on ubuntu

  1. On all three nodes, add the GPG key and package repository, then install Confluent and Java:
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-jdk confluent-community-2.12

2. On all three nodes, edit the hosts file:

sudo vi /etc/hosts
  1. Add the following to the hosts file on all three servers. Use the private IP addresses of your three servers (you can find
    them in Cloud Playground):
<server 1 private IP> zoo1
<server 2 private IP> zoo2
<server 3 private IP> zoo3

4. Save and exit the file on each server.

5. On each server, edit the Zookeeper config file:

sudo vi /etc/kafka/

6. Delete the contents of the config file, and add the following:

  1. Save and exit the file on each server.
  2. Set the Zookeeper ID for each server:
sudo vi /var/lib/zookeeper/myid

9.On each server, set the contents of /var/lib/zookeeper/myid to the server’s ID:

On Server 1, enter 1 .
On Server 2, enter 2 .
On Server 3, enter 3 .
  1. Save and exit the file on each server.
  2. On each server, edit the Kafka config file:
sudo vi /etc/kafka/
  • Now, we need to edit the , advertised.listeners , and zookeeper.connect in the config file.
  1. Set to the appropriate ID for each server ( 1 on Server 1, 2 on Server 2, and 3 on Server 3).
  2. For advertised.listeners , un-comment the line and change to the hostname for each server —
zoo1 , zoo2 , or zoo3 — as appropriate.
  1. In each config file, set zookeeper.connect to zoo1:2181 .
  2. On each server, start and enable the Zookeeper service:
sudo systemctl start confluent-zookeeper
sudo systemctl enable confluent-zookeeper
  1. Wait a few seconds, and then do the same for the Kafka service on each server:
sudo systemctl start confluent-kafka
sudo systemctl enable confluent-kafka
  1. Check the services on each server to make sure they are running. Both services should be active (running) on all three
sudo systemctl status confluent

*They should both be in the active (running) state on all servers.

15. Test your cluster by listing the current topics:

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

Since you have not created any topics yet, you will only see a default topic. The output should look like this:

Leave a Reply

Your email address will not be published.