How to Set Up Kafka Servers on CentOS

How to Set Up Kafka Servers on CentOS
Written by Abhishek JalanApril 18, 2020
4 min read
Kafka
4 VIEWS 1 LIKES 1 DISLIKES SHARE
1 LIKES 1 DISLIKES 4 VIEWS SHARE
Abhishek Jalan

Founder of Wikiance, DevOps Engineer

In this lab we will setup new Kafka Servers on CentOS platform

Create three servers with the following specifications:

Distribution: Ubuntu 18.04

Min Specs: 2GB RAM/20GB HDD/1CPU

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

Configure ZooKeeper

On all three nodes, edit the hosts file:

sudo vi /etc/hosts

Add the following entries to the hosts file:

10.0.1.101 zoo1
10.0.1.102 zoo2
10.0.1.103 zoo3

Edit the zookeeper config file:

sudo vi /etc/kafka/zookeeper.properties

Delete the contents of the config file and replace them with 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 zookeeper ID for each server:

sudo vi /var/lib/zookeeper/myid

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

Edit the kafka config file:

sudo vi /etc/kafka/server.properties

Edit the broker.id 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).

Set zookeeper.connect to zoo1:2181:

broker.id=<server id 1, 2, or 3>

...

zookeeper.connect=zoo1:2181

Start ZooKeeper and Kafka

Get the ZooKeeper and Kafka services started, plus enable them:

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 that they are running:

sudo systemctl status confluent*

We can test our cluster by listing the current topics:

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

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

_confluent.support.metrics

Kafka
Centos
4 VIEWS 1 LIKES 1 DISLIKES SHARE
1 LIKES 1 DISLIKES 4 VIEWS SHARE
Was this blog helpful?
You must be Logged in to comment
Code Block
Abhishek Jalan
Founder of Wikiance, DevOps Engineer
14 Blog Posts
4 Discussion Threads
Trending Categories
37
Software1
DevOps15
Frontend Development4
Backend Development2
Server Administration1
Linux Administration5
Data Center0
Sentry0
Terraform2
Ansible0
Docker3
Penetration Testing0
Kubernetes0
NGINX0
JenkinsX0
Jenkins2
SSL0
Ethical-Hacking1
Python0
NodeJs1
RedHat0
Github0
AngularJs0
Google Cloud Platform (GCP)0
SonarQube0
Amazon Web Service (AWS)0
VMware0
Blockchain0
Snipe-IT1
MongoDB0