How To Install Apache Kafka on Fedora 43

Install Apache Kafka on Fedora 43

Apache Kafka stands as the industry-leading distributed streaming platform for building real-time data pipelines and streaming applications. Organizations like Netflix, LinkedIn, and Uber rely on Kafka to process trillions of messages daily with exceptional throughput and reliability. This comprehensive guide walks you through installing Apache Kafka on Fedora 43 using the modern KRaft consensus protocol, which eliminates ZooKeeper dependency and simplifies cluster management. Whether you’re developing microservices architectures, implementing event-driven systems, or building real-time analytics pipelines, this tutorial provides detailed step-by-step instructions for a production-ready Kafka installation.

Understanding Apache Kafka Architecture

Apache Kafka functions as a distributed streaming platform designed for high-throughput, fault-tolerant message processing across multiple nodes. The platform organizes data into topics, which serve as named categories for message storage. Each topic consists of multiple partitions that enable parallel processing and horizontal scaling across broker nodes.

Kafka brokers form the fundamental building blocks of the cluster, handling message storage, replication, and client request processing. Multiple brokers work together to provide fault tolerance through data replication and automatic failover mechanisms. The modern KRaft mode integrates consensus mechanisms directly into Kafka brokers, eliminating the need for external ZooKeeper coordination. This architectural improvement reduces operational complexity while enhancing cluster startup times and overall system reliability.

Producers publish messages to specific topics while consumers subscribe to topics for message consumption. This decoupled architecture enables flexible, scalable communication patterns between distributed application components, supporting millions of messages per second with proper configuration.

Prerequisites and System Requirements

Before beginning the Apache Kafka installation on Fedora 43, verify your system meets essential requirements for optimal performance and stability. Your server needs administrative privileges through root or sudo access for system-level configurations and service management. Ensure stable internet connectivity for downloading packages and dependencies from official repositories.

Hardware specifications play a crucial role in Kafka performance. Allocate minimum 4GB RAM for development environments, though production deployments typically require 8GB or more. Kafka’s performance scales with available memory for buffer management and caching. Reserve at least 20GB free disk space for Kafka binaries, logs, and data storage. Multi-core processors enhance Kafka’s concurrent processing capabilities, with dual-core CPUs serving as the baseline recommendation.

Network configuration requires proper hostname resolution and ensures ports 9092 (Kafka broker) and 9093 (controller) remain available for service binding. Configure firewall settings to permit inbound connections on these ports for client communication and cluster coordination. Static IP addresses are recommended for production environments to maintain consistent cluster connectivity.

Step 1: System Preparation and Updates

Proper system preparation establishes a stable foundation for Apache Kafka installation on Fedora 43. Begin by updating your system with the latest packages and security patches to ensure compatibility with Kafka dependencies.

Execute the following commands to update your Fedora 43 system:

sudo dnf clean all
sudo dnf update -y

Install essential development tools and utilities required for Kafka operations:

sudo dnf groupinstall "Development Tools" -y
sudo dnf install wget curl vim nano htop -y

Configure firewall rules to permit Kafka communication on required ports:

sudo firewall-cmd --permanent --add-port=9092/tcp
sudo firewall-cmd --permanent --add-port=9093/tcp
sudo firewall-cmd --reload

Verify the firewall configuration:

sudo firewall-cmd --list-ports

Check SELinux status and configure appropriate policies:

sestatus

If SELinux is enforcing, you may need to configure specific boolean policies for Kafka operations. Document the current SELinux mode for troubleshooting purposes. These preparation steps create a secure, updated environment optimized for Apache Kafka deployment.

Step 2: Installing Java OpenJDK

Apache Kafka requires Java Runtime Environment version 11 or higher for execution. The platform runs on the Java Virtual Machine, making Java installation a mandatory prerequisite. OpenJDK provides a stable, open-source Java implementation perfectly suited for Kafka deployments on Fedora 43.

Install OpenJDK 17, the latest long-term support release recommended for modern Kafka installations:

sudo dnf install java-17-openjdk java-17-openjdk-devel -y

Verify the Java installation and version compatibility:

java --version
javac --version

The output should display OpenJDK 17 or higher, confirming successful installation. Configure the JAVA_HOME environment variable for consistent Java runtime detection across the system:

sudo nano /etc/environment

Add the following lines to establish system-wide Java configuration:

JAVA_HOME=/usr/lib/jvm/java-17-openjdk
PATH=$PATH:$JAVA_HOME/bin

Apply the environment configuration:

source /etc/environment

Verify JAVA_HOME configuration:

echo $JAVA_HOME
which java

For systems with multiple Java versions installed, use the alternatives system to manage Java installations:

sudo alternatives --config java

This Java configuration provides an optimal runtime environment for Apache Kafka operations with appropriate version compatibility and system-wide accessibility.

Step 3: Downloading and Installing Apache Kafka

Download the latest Apache Kafka release from the official Apache Software Foundation distribution repository. The binary distribution includes all necessary components for immediate deployment without compilation requirements.

Navigate to a temporary directory for downloading Kafka:

cd /tmp

Download the latest stable Kafka release with Scala 2.13:

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

Verify download integrity using SHA512 checksum:

wget https://downloads.apache.org/kafka/4.1.1/kafka_2.13-4.1.1.tgz.sha512
sha512sum -c kafka_2.13-4.1.1.tgz.sha512

Extract the Kafka archive:

tar -xzf kafka_2.13-4.1.1.tgz

Move Kafka to the system directory for centralized management:

sudo mv kafka_2.13-4.1.1 /opt/kafka

Create a symbolic link for version-independent access:

sudo ln -sf /opt/kafka /opt/kafka-current

The Kafka installation directory contains several important subdirectories. The bin/ directory houses executable scripts and administrative tools. Configuration files reside in config/, while libs/ contains Java dependencies. Understanding this directory structure helps with troubleshooting and configuration management.

Configure environment variables for convenient Kafka command access:

echo 'export KAFKA_HOME=/opt/kafka' >> ~/.bashrc
echo 'export PATH=$PATH:$KAFKA_HOME/bin' >> ~/.bashrc
source ~/.bashrc

Verify Kafka installation by checking available commands:

ls -la /opt/kafka/bin/kafka-*

This installation provides a clean, organized Kafka deployment ready for KRaft mode configuration and service initialization.

Step 4: Creating Dedicated Kafka User

Running services as root poses significant security risks. Create a dedicated system user for Kafka operations following the principle of least privilege. This isolation enhances system security and simplifies permission management across Kafka directories.

Create a system user specifically for Kafka:

sudo useradd -r -s /bin/false kafka

The -r flag creates a system account, while -s /bin/false prevents direct login access. Configure directory ownership for the kafka user:

sudo chown -R kafka:kafka /opt/kafka

Create dedicated directories for Kafka data and logs:

sudo mkdir -p /opt/kafka/kafka-logs
sudo mkdir -p /opt/kafka/logs

Set appropriate ownership and permissions:

sudo chown -R kafka:kafka /opt/kafka/kafka-logs
sudo chown -R kafka:kafka /opt/kafka/logs
sudo chmod 755 /opt/kafka/kafka-logs
sudo chmod 755 /opt/kafka/logs

Verify the permission configuration:

ls -la /opt/kafka/

The kafka user should have read, write, and execute permissions on all necessary directories. This security configuration ensures Kafka operates with minimal privileges while maintaining full functionality.

Step 5: Configuring Kafka in KRaft Mode

KRaft mode represents the modern approach to Apache Kafka deployment, eliminating ZooKeeper dependency through integrated consensus mechanisms. This architecture simplifies cluster management while improving performance and reducing operational overhead. KRaft uses the Raft consensus protocol for metadata management, providing faster recovery times and enhanced scalability.

Generate a unique cluster UUID required for KRaft initialization:

cd /opt/kafka
./bin/kafka-storage.sh random-uuid

Save the generated UUID, which should resemble: J7s9-K8fQ_WnAGVTB2fiZQ. This unique identifier distinguishes your Kafka cluster from others. Create a backup of the default KRaft configuration:

sudo cp config/kraft/server.properties config/kraft/server.properties.backup

Edit the KRaft server properties file:

sudo nano config/kraft/server.properties

Configure essential KRaft parameters:

# Process roles (combined broker and controller for single-node setup)
process.roles=broker,controller

# Unique node identifier
node.id=1

# Controller quorum voters configuration
controller.quorum.voters=1@localhost:9093

# Network listener configuration
listeners=PLAINTEXT://:9092,CONTROLLER://:9093
advertised.listeners=PLAINTEXT://localhost:9092

# Controller listener name
controller.listener.names=CONTROLLER

# Data storage directory
log.dirs=/opt/kafka/kafka-logs

# Network thread configuration
num.network.threads=3
num.io.threads=8

# Socket buffer configuration
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600

Add performance optimization settings:

# Log retention configuration
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000

# Compression settings
compression.type=producer

# Default replication settings
num.partitions=1
default.replication.factor=1

Format the Kafka storage with your generated UUID:

sudo -u kafka ./bin/kafka-storage.sh format -t J7s9-K8fQ_WnAGVTB2fiZQ -c config/kraft/server.properties

The format operation initializes metadata storage for KRaft mode. Execute this command only once during initial setup, as reformatting destroys existing data. This KRaft configuration establishes a robust foundation for modern Kafka deployment with integrated consensus management.

Step 6: Creating Systemd Service for Kafka

Systemd service management provides automated startup, monitoring, and restart capabilities for Apache Kafka. Creating a dedicated service file ensures Kafka operates reliably as a system daemon with proper resource management and failure recovery.

Create the Kafka systemd service file:

sudo nano /etc/systemd/system/kafka.service

Add the comprehensive service configuration:

[Unit]
Description=Apache Kafka Server (KRaft Mode)
Documentation=https://kafka.apache.org/documentation.html
Requires=network.target
After=network.target

[Service]
Type=simple
User=kafka
Group=kafka
Environment=JAVA_HOME=/usr/lib/jvm/java-17-openjdk
Environment=KAFKA_HEAP_OPTS=-Xmx1G -Xms1G
Environment=KAFKA_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35
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
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=kafka
LimitNOFILE=65536
LimitNPROC=65536

[Install]
WantedBy=multi-user.target

The service configuration includes several critical components. The Environment directives set Java paths and JVM parameters for optimal performance. The LimitNOFILE and LimitNPROC settings increase file descriptor and process limits to handle high-throughput workloads.

Reload the systemd daemon to recognize the new service:

sudo systemctl daemon-reload

Enable Kafka to start automatically on system boot:

sudo systemctl enable kafka.service

Start the Kafka service:

sudo systemctl start kafka.service

Check the service status to verify successful startup:

sudo systemctl status kafka.service

The output should display “active (running)” status with recent startup logs. Monitor real-time service logs:

sudo journalctl -u kafka.service -f

These systemd configurations ensure robust, secure, and manageable Kafka service deployment with comprehensive monitoring and automatic recovery capabilities.

Step 7: Verifying Kafka Installation

Comprehensive verification validates that Apache Kafka operates correctly and is ready for production workloads. Systematic testing confirms all components function properly and network connectivity works as expected.

Verify the service status:

sudo systemctl status kafka --no-pager -l

Check that Kafka processes are running:

ps aux | grep kafka

Verify network port binding:

sudo ss -tuln | grep -E ':(9092|9093)'

The output should show Kafka listening on port 9092 (broker) and 9093 (controller). Test broker API connectivity:

cd /opt/kafka
./bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092

This command displays supported API versions, confirming successful broker connectivity. Create a test topic to verify full functionality:

./bin/kafka-topics.sh --create --topic test-topic --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1

List all topics to confirm creation:

./bin/kafka-topics.sh --list --bootstrap-server localhost:9092

Describe the topic details:

./bin/kafka-topics.sh --describe --topic test-topic --bootstrap-server localhost:9092

Perform producer-consumer testing to validate end-to-end message flow. Open a new terminal and start the console producer:

cd /opt/kafka
./bin/kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092

Type several test messages, pressing Enter after each. In another terminal, start the console consumer:

cd /opt/kafka
./bin/kafka-console-consumer.sh --topic test-topic --from-beginning --bootstrap-server localhost:9092

All messages sent by the producer should appear in the consumer output. This confirms successful message streaming through your Kafka installation. These verification steps validate complete Kafka functionality and operational readiness.

Step 8: Basic Kafka Operations

Understanding fundamental Kafka operations enables effective cluster management and application development. Master these essential commands for daily Kafka administration and troubleshooting.

Create topics with custom configurations:

./bin/kafka-topics.sh --create --topic custom-topic --bootstrap-server localhost:9092 --partitions 6 --replication-factor 1 --config retention.ms=86400000

Modify existing topic configurations:

./bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name custom-topic --alter --add-config min.insync.replicas=1

Delete topics when necessary:

./bin/kafka-topics.sh --delete --topic custom-topic --bootstrap-server localhost:9092

Use the console producer for testing and development:

./bin/kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092 --property parse.key=true --property key.separator=:

Start a consumer group for distributed message consumption:

./bin/kafka-console-consumer.sh --topic test-topic --group my-consumer-group --bootstrap-server localhost:9092

List active consumer groups:

./bin/kafka-consumer-groups.sh --list --bootstrap-server localhost:9092

Describe consumer group details and lag:

./bin/kafka-consumer-groups.sh --describe --group my-consumer-group --bootstrap-server localhost:9092

Check disk usage for log directories:

du -sh /opt/kafka/kafka-logs/*

These operations provide essential tools for managing Kafka clusters effectively and diagnosing performance issues.

Common Troubleshooting Issues

Apache Kafka installations may encounter various issues related to configuration, permissions, networking, or resource constraints. Systematic troubleshooting approaches resolve these problems efficiently while maintaining system stability.

Java Version Conflicts: Multiple JDK installations can cause compatibility issues. Verify Java configuration:

sudo alternatives --display java
echo $JAVA_HOME
which java

Set the correct Java version using the alternatives system if multiple versions are installed.

Port Binding Errors: Network interface restrictions prevent proper service startup:

sudo ss -tlnp | grep -E ':(9092|9093)'
sudo lsof -i :9092

Identify conflicting processes and stop them, or configure Kafka to use alternative ports.

Permission Problems: File ownership issues affect service operation:

sudo chown -R kafka:kafka /opt/kafka
sudo chmod -R 755 /opt/kafka/bin/
sudo restorecon -R /opt/kafka/

Check SELinux contexts if permission denied errors persist in enforcing mode.

Memory Allocation Issues: Insufficient memory causes startup failures. Reduce heap size for limited memory systems:

sudo nano /etc/systemd/system/kafka.service

Modify the heap settings to Environment=KAFKA_HEAP_OPTS=-Xmx512M -Xms512M for systems with limited RAM.

Log Analysis: Examine service logs for root cause analysis:

sudo journalctl -u kafka --since "1 hour ago" --no-pager
tail -f /opt/kafka/logs/server.log

Disk Space Management: Log accumulation exhausts storage:

df -h /opt/kafka/kafka-logs

Adjust log retention settings in server.properties or manually clean old log segments.

Connection Refused Errors: Verify listener configuration and network connectivity:

telnet localhost 9092
nc -zv localhost 9092

Check that advertised.listeners matches your actual network configuration. These troubleshooting procedures address common Kafka deployment issues, ensuring rapid problem resolution and system restoration.

Security Best Practices

Implementing comprehensive security measures protects Apache Kafka installations from unauthorized access, data breaches, and service disruptions. Enterprise deployments demand multiple layers of protection for production environments.

Run Kafka under a dedicated system user with minimal privileges:

sudo useradd -r -s /bin/false kafka
sudo chown -R kafka:kafka /opt/kafka

Never execute Kafka services as the root user. Secure configuration and data directories with restrictive permissions:

sudo chmod 700 /opt/kafka/config
sudo chmod 700 /opt/kafka/kafka-logs
sudo chmod 600 /opt/kafka/config/kraft/server.properties

Configure comprehensive firewall rules restricting access to specific IP ranges:

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="9092" accept'
sudo firewall-cmd --reload

Implement regular system updates and security patches:

sudo dnf update -y

Configure log rotation to manage disk space and maintain audit trails:

sudo nano /etc/logrotate.d/kafka

Add rotation configuration for Kafka logs with appropriate retention periods. Monitor system logs regularly for suspicious activity and unauthorized access attempts. Establish backup procedures for configuration files and critical data directories. These security implementations provide enterprise-grade protection for Apache Kafka deployments against common threats.

Congratulations! You have successfully installed Apache Kafka. Thanks for using this tutorial for installing Apache Kafka on your Fedora 43 Linux system. For additional or useful information, we recommend you check the official Apache website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
r00t is a dedicated and highly skilled Linux Systems Administrator with over a decade of progressive experience in designing, deploying, and maintaining enterprise-grade Linux infrastructure. His professional journey began in the telecommunications industry, where early exposure to Unix-based operating systems ignited a deep and enduring passion for open-source technologies and server administration.​ Throughout his career, r00t has demonstrated exceptional proficiency in managing large-scale Linux environments, overseeing more than 300 servers across development, staging, and production platforms while consistently achieving 99.9% system uptime. He holds advanced competencies in Red Hat Enterprise Linux (RHEL), Debian, and Ubuntu distributions, complemented by hands-on expertise in automation tools such as Ansible, Terraform, Bash scripting, and Python.

Related Posts