✅ Correct — as of now, the latest Apache Kafka version is 4.1.0 (released October 2025). Let’s update the installation guide for Kafka 4.1.0 on ParrotOS (Debian-based).
Kafka 4.x requires Java 11+. Let’s install the latest OpenJDK and some common tools:
sudo apt update
sudo apt install default-jdk curl wget tar -y
java -versionMake sure it prints something like:
openjdk version "17.0.10" ...
Go to /opt (or wherever you want Kafka installed):
cd /opt
sudo wget https://downloads.apache.org/kafka/4.1.0/kafka_2.13-4.1.0.tgz
sudo tar -xzf kafka_2.13-4.1.0.tgz
sudo mv kafka_2.13-4.1.0 kafkaNow you have Kafka 4.1.0 installed at /opt/kafka.
Since Kafka 4.x fully supports KRaft mode (Zookeeper-free), it’s the recommended setup.
cd /opt/kafka
KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"
echo $KAFKA_CLUSTER_IDbin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.propertiesbin/kafka-server-start.sh config/kraft/server.propertiesKafka will start on port 9092 by default.
Open a new terminal.
cd /opt/kafka
bin/kafka-topics.sh --create --topic test-topic --bootstrap-server localhost:9092bin/kafka-topics.sh --list --bootstrap-server localhost:9092bin/kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092(Type some messages, then press Ctrl+C)
bin/kafka-console-consumer.sh --topic test-topic --from-beginning --bootstrap-server localhost:9092Press Ctrl+C in the Kafka terminal to stop it cleanly.
echo 'export PATH=$PATH:/opt/kafka/bin' >> ~/.bashrc
source ~/.bashrcNow you can run commands like kafka-topics.sh directly from anywhere.
##kafka as systemd service Okay now lets do clean Kafka 4.1.0 installation and setup on ParrotOS**, including a systemd service, running in KRaft (no-Zookeeper) mode.
ParrotOS is based on Debian, so these steps will also work for Debian 12 or Ubuntu 22.04+.
sudo apt update && sudo apt upgrade -y
sudo apt install default-jdk curl wget tar -yConfirm Java version:
java -versionOutput should look like:
openjdk version "17.0.x"
We’ll install Kafka under /opt/kafka.
cd /opt
sudo wget https://downloads.apache.org/kafka/4.1.0/kafka_2.13-4.1.0.tgz
sudo tar -xzf kafka_2.13-4.1.0.tgz
sudo mv kafka_2.13-4.1.0 kafka
sudo rm kafka_2.13-4.1.0.tgzIt’s best practice not to run Kafka as root.
sudo useradd -r -m -U -d /opt/kafka -s /bin/bash kafka
sudo chown -R kafka:kafka /opt/kafkaKafka 4.x uses KRaft (no Zookeeper). Switch to the Kafka user and configure:
sudo -u kafka -s
cd /opt/kafkaGenerate a cluster ID:
KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"
echo $KAFKA_CLUSTER_IDFormat the storage:
bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.propertiesThis initializes Kafka’s internal metadata storage.
Before systemd setup, test Kafka manually:
bin/kafka-server-start.sh config/kraft/server.propertiesIt should start successfully, showing logs like:
Kafka Server started
Press Ctrl+C to stop it. If that worked, proceed to service setup.
Exit to your main (sudo) user:
exitCreate a new systemd service file:
sudo nano /etc/systemd/system/kafka.servicePaste this:
[Unit]
Description=Apache Kafka Server (KRaft mode)
Documentation=https://kafka.apache.org/documentation/
After=network.target
[Service]
Type=simple
User=kafka
ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/kraft/server.properties
ExecStop=/opt/kafka/bin/kafka-server-stop.sh
Restart=on-abnormal
Environment="KAFKA_HEAP_OPTS=-Xmx512M -Xms256M"
[Install]
WantedBy=multi-user.targetSave and exit (Ctrl+O, Enter, Ctrl+X).
Reload systemd:
sudo systemctl daemon-reloadEnable Kafka to start on boot:
sudo systemctl enable kafkaStart Kafka:
sudo systemctl start kafkaCheck status:
sudo systemctl status kafkaYou should see:
Active: active (running)
Check the port:
sudo netstat -tulnp | grep 9092Then test by creating a topic:
sudo -u kafka /opt/kafka/bin/kafka-topics.sh --create --topic test-topic --bootstrap-server localhost:9092List topics:
sudo -u kafka /opt/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092Produce a message:
sudo -u kafka /opt/kafka/bin/kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092Consume it:
sudo -u kafka /opt/kafka/bin/kafka-console-consumer.sh --topic test-topic --from-beginning --bootstrap-server localhost:9092| Command | Description |
|---|---|
sudo systemctl start kafka |
Start Kafka |
sudo systemctl stop kafka |
Stop Kafka |
sudo systemctl restart kafka |
Restart Kafka |
sudo systemctl status kafka |
Check Kafka status |
journalctl -u kafka -f |
View Kafka logs live |
You now have:
- Apache Kafka 4.1.0
- Running in KRaft mode (no Zookeeper)
- Managed via systemd
- Auto-starts on boot
- Tested producer/consumer functionality
Perfect — let’s do a clean reset and reinstall Kafka 4.1.0 so you can run it as your normal user (with or without sudo), not as a dedicated kafka user.
I’ll walk you through completely removing the old setup and starting fresh, step by step 👇
sudo systemctl stop kafka 2>/dev/null
sudo systemctl disable kafka 2>/dev/null
sudo rm -f /etc/systemd/system/kafka.service
sudo systemctl daemon-reloadRemove the old Kafka user and home directory:
sudo userdel -r kafka 2>/dev/nullRemove the old Kafka directory:
sudo rm -rf /opt/kafkaNow you have a clean slate. ✅
Make sure Java and basic tools are installed:
sudo apt update
sudo apt install default-jdk curl wget tar -y
java -versionYou should see something like:
openjdk version "17.0.10"
Install Kafka to /opt/kafka as your normal user (using sudo only where needed):
cd /opt
sudo wget https://downloads.apache.org/kafka/4.1.0/kafka_2.13-4.1.0.tgz
sudo tar -xzf kafka_2.13-4.1.0.tgz
sudo mv kafka_2.13-4.1.0 kafka
sudo rm kafka_2.13-4.1.0.tgz
sudo chown -R $USER:$USER /opt/kafkaNow Kafka belongs to your regular user.
Kafka 4.x doesn’t always include the config/kraft/ folder. Let’s make it manually.
mkdir -p /opt/kafka/config/kraft
nano /opt/kafka/config/kraft/server.propertiesPaste this:
# Kafka 4.1.0 KRaft Configuration
process.roles=broker,controller
node.id=1
listeners=PLAINTEXT://:9092,CONTROLLER://:9093
controller.listener.names=CONTROLLER
controller.quorum.voters=1@localhost:9093
advertised.listeners=PLAINTEXT://localhost:9092
log.dirs=/opt/kafka/data/kraft-combined-logs
metadata.log.dir=/opt/kafka/data/metadata
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
auto.create.topics.enable=true
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
group.initial.rebalance.delay.ms=0Save (Ctrl+O, Enter, Ctrl+X).
cd /opt/kafka
KAFKA_CLUSTER_ID="$(bin/kafka-storage.sh random-uuid)"
echo $KAFKA_CLUSTER_IDThen:
bin/kafka-storage.sh format -t $KAFKA_CLUSTER_ID -c config/kraft/server.properties✅ Output should say something like:
Formatting /opt/kafka/data/metadata with clusterId ...
cd /opt/kafka
bin/kafka-server-start.sh config/kraft/server.propertiesIf you see:
Kafka Server started
then everything’s working fine. Press Ctrl+C to stop it.
Now create a service that runs Kafka as your own user, not kafka.
sudo nano /etc/systemd/system/kafka.servicePaste this:
[Unit]
Description=Apache Kafka 4.1.0 Server (KRaft mode)
After=network.target
[Service]
Type=simple
User=%i
ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/kraft/server.properties
ExecStop=/opt/kafka/bin/kafka-server-stop.sh
Restart=on-failure
Environment="KAFKA_HEAP_OPTS=-Xmx1G -Xms512M"
[Install]
WantedBy=multi-user.target💡 If you want the service to always run under your current user, replace:
User=%i
with:
User=yourusername
Save and exit.
Reload and start:
sudo systemctl daemon-reload
sudo systemctl enable kafka
sudo systemctl start kafka
sudo systemctl status kafkaYou should see:
Active: active (running)
Check port:
sudo netstat -tulnp | grep 9092Create a test topic:
/opt/kafka/bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092List topics:
/opt/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092Produce and consume:
/opt/kafka/bin/kafka-console-producer.sh --topic test --bootstrap-server localhost:9092(Type a few messages, then Ctrl+C)
/opt/kafka/bin/kafka-console-consumer.sh --topic test --from-beginning --bootstrap-server localhost:9092| Command | Description |
|---|---|
sudo systemctl start kafka |
Start Kafka |
sudo systemctl stop kafka |
Stop Kafka |
sudo systemctl restart kafka |
Restart Kafka |
sudo systemctl status kafka |
Check status |
journalctl -u kafka -f |
View live logs |
✅ Now you have Kafka 4.1.0 fully running under your own user (no kafka user), systemd-managed, in KRaft mode, ready for development or local testing.