# Kafka Cluster Installation on Linux

Published 2022-12-03

This tutorial explains to you how to install Apache Kafka Cluster on Linux. This tutorial explains step-by-step how to install Kafka Cluster on a Linux machine.

Once you have installed Zookeeper Cluster you can install Kafka Cluster as well.

Our environment has :

  • 3 machines with Linux (CentOS 8) on them
  • Zookeeper cluster is installed on them

Please take a look at the tutorial named Zookeeper cluster installation to see more details about the environment we use for this installation.

Here are the steps for installing Kafka Server in Cluster:

  1. Create Kafka Server data directory
mkdir -p /kafka/kafka_2.13-2.8.0/data/kafka
  1. Add file limits configs - allow to open 100,000 file descriptors (as root user)
echo "* hard nofile 100000
* soft nofile 100000" | sudo tee --append /etc/security/limits.conf
  1. Configure Kafka server properties

Take a look at the image below:

Put these parameters into the server.properties configuration file (in my case it is /kafka/kafka_2.13-2.8.0/config/ folder).

This file must be adapted for each Kafka server (the parameters which must modified for each server is marked in the image above).

In order to get this text easily, I will add the image content below:

# This is the unique id of each broker (myid)

# Set to the external address (host/IP) so that clients can correctly connect to it

# Switch to enable topic deletion or not, default value is false

# A comma seperated list of directories under which to store log files

# The default number of log partitions per topic.

# we will have 3 brokers so the default replication factor could be 2 or 3

# number of ISR to have in order to minimize data loss

# this will delete data after a week

# The maximum size of a log segment file (when this size is reached a new log segment will be created)

# The interval at which log segments are checked to see if they can
# be deleted according to the retention policies

# Zookeeper connection string (Kafka server needs to be connected to Zookeeper server)

# Timeout in ms for connecting to zookeeper

#(by default) Kafka will create topics automatically when you send messages to non-existing topics.
# In production it is better to set it to false
  1. Start Kafka Server

Before you start Kafka server you must start the Zookeeper server. For this tutorial, we consider Zookeeper is already running. For more details about this subject you can take a look at the tutorial named Start/Stop Apache Kafka and Zookeeper.

cd /kafka/kafka_2.13-2.8.0
kafka-server-start.sh ./config/server.properties

When Kafka server is running you will see something like this: