Refer : https://www.digitalocean.com/community/tutorials/how-to-install-apache-kafka-on-ubuntu-20-04

Step 1: Create Kafka User and Download Binaries

  1. Create a new user

    sudo useradd -m -s /bin/bash kafka

  2. Grant sudo privileges

    sudo visudo

    Add this line at the bottom:

    kafka ALL=(ALL) ALL

  3. Switch to the kafka user

    su -l kafka

  4. Create a Downloads directory and move into it

    mkdir -p ~/Downloads

    cd ~/Downloads

  5. Download Kafka binaries

    wget https://downloads.apache.org/kafka/3.6.0/kafka_2.13-3.6.0.tgz -O kafka.tgz

  6. Create Kafka directory and extract binaries

    mkdir ~/kafka

    tar -xvzf kafka.tgz -C ~/kafka --strip-components=1

Step 2: Configure Kafka

  1. Open Kafka server configuration

    nano ~/kafka/config/server.properties

  2. Enable topic deletion

    Set this property inside the file:

    delete.topic.enable=true

Step 3: Create Systemd Services for Kafka:

Step 4: Run a zookeeper along with kafka