Apache Kafka is often better suited for high load projects than message brokers like RabbitMQ, ActiveMQ. Installing Apache Kafka on a dedicated or virtual Ubuntu Server 20.04 server is necessary for running highly loaded applications and ensuring throughput. Kafka is resource demanding: RAM should be at least 4 GB.
Before you roll Apache Kafka on Ubuntu 20.04, you need to perform initial configuration:
create a user with sudo privileges;
start and configure the firewall;
close SSH access to the server for root users.
To install Kafka, you need to check for up-to-date package versions beforehand. This is done with the command:
$ sudo apt update.
Java and Scala must be available on the virtual / dedicated server to work correctly. Also jre is required to run Kafka. Innstall is done with the command:
$ sudo apt install default-jre
When finished, check the current version of Java:
$ java -version
Kafka runs over the network, so a special account is required to work (security, reducing the risk of compromise). Create it with the command:
$ sudo adduser kafka
After login($ su -l kafka
) change directory and go to tmp. The command is standard:
$ cd /tmp
To download Kafka, the classic command using the terminal curl is used. To download Apache Kafka enter:
$ curl -LO https://dlcdn.apache.org/kafka/3.2.1/kafka_2.13-3.2.1.tgz
Note that the developer periodically updates the software (in February 2023 the current version is 3.4.0.
Create a directory into which to unpack the distribution. Command in terminal:
$ mkdir ~/kafka
Change the directory to go to the desired folder and there already unpack the archive
$ tar -xvzf /tmp/kafka_2.13-3.2.1.tgz --strip 1.
You have installed Apache Kafka on Ubuntu 20.04. Now it remains to configure the correct operation.