Apache Kafka

Comprehensive installation and configuration guide for Apache Kafka distributed event streaming platform with FOSS alternatives including RabbitMQ, Apache Pulsar, NATS, Redis Streams, and EventStore

Message queues🟡 intermediate45 min⏱️ 45-90 minutes

Apache Kafka is a distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. It provides a unified, high-throughput, low-latency platform for handling real-time data feeds.

FOSS Alternatives:

  • RabbitMQ - Feature-rich message broker with excellent AMQP support
  • Apache Pulsar - Cloud-native distributed messaging and streaming platform
  • NATS - High-performance messaging system for cloud native applications
  • Redis Streams - Lightweight streaming solution built into Redis
  • EventStore - Open-source event store with complex event processing capabilities
  • 1. Prerequisites

    Hardware Requirements

  • CPU: Minimum 2 cores, recommended 4+ cores for production
  • RAM: Minimum 4GB, recommended 8GB+ for production workloads
  • Storage: Minimum 20GB, recommended SSD with 100GB+ for production
  • Network: Reliable network connectivity with low latency between brokers
  • Software Requirements

  • Operating System: Linux (RHEL/CentOS 7+, Ubuntu 18.04+, Debian 9+)
  • Java: OpenJDK 11 or Oracle JDK 11+ (Kafka 2.8+ requires Java 11 minimum)
  • Apache ZooKeeper: 3.4.6+ (for Kafka versions before 2.8, optional for 2.8+)
  • Network Requirements

  • Ports: 9092 (Kafka broker), 2181 (ZooKeeper), 9093 (SSL), 9999 (JMX)
  • Firewall: Configure appropriate rules for cluster communication
  • DNS: Proper hostname resolution between cluster nodes
  • User Permissions

  • Non-root user with sudo privileges
  • User should be member of appropriate groups (kafka, zookeeper)
  • 2. Installation

    RHEL/CentOS/Rocky Linux/AlmaLinux/Fedora

    bash
    # Update system packages
    sudo dnf update -y
    
    # Install Java 11
    sudo dnf install -y java-11-openjdk java-11-openjdk-devel
    
    # Set JAVA_HOME
    echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk' >> ~/.bashrc
    source ~/.bashrc
    
    # Create kafka user
    sudo useradd -r -s /bin/false kafka
    
    # Create installation directory
    sudo mkdir -p /opt/kafka
    sudo chown kafka:kafka /opt/kafka
    
    # Download and install Kafka
    cd /tmp
    wget https://downloads.apache.org/kafka/2.8.2/kafka_2.13-2.8.2.tgz
    tar -xzf kafka_2.13-2.8.2.tgz
    sudo mv kafka_2.13-2.8.2/* /opt/kafka/
    sudo chown -R kafka:kafka /opt/kafka
    
    # Create data directories
    sudo mkdir -p /var/kafka-logs
    sudo mkdir -p /var/zookeeper
    sudo chown kafka:kafka /var/kafka-logs /var/zookeeper
    
    # Add kafka to PATH
    echo 'export PATH="$PATH:/opt/kafka/bin"' | sudo tee -a /etc/environment

    Debian/Ubuntu

    bash
    # Update package lists
    sudo apt update && sudo apt upgrade -y
    
    # Install Java 11
    sudo apt install -y openjdk-11-jdk
    
    # Set JAVA_HOME
    echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' >> ~/.bashrc
    source ~/.bashrc
    
    # Create kafka user
    sudo useradd -r -s /bin/false kafka
    
    # Create installation directory
    sudo mkdir -p /opt/kafka
    sudo chown kafka:kafka /opt/kafka
    
    # Download and install Kafka
    cd /tmp
    wget https://downloads.apache.org/kafka/2.8.2/kafka_2.13-2.8.2.tgz
    tar -xzf kafka_2.13-2.8.2.tgz
    sudo mv kafka_2.13-2.8.2/* /opt/kafka/
    sudo chown -R kafka:kafka /opt/kafka
    
    # Create data directories
    sudo mkdir -p /var/kafka-logs
    sudo mkdir -p /var/zookeeper
    sudo chown kafka:kafka /var/kafka-logs /var/zookeeper
    
    # Add kafka to PATH
    echo 'export PATH="$PATH:/opt/kafka/bin"' | sudo tee -a /etc/environment

    Arch Linux/Manjaro/EndeavourOS

    bash
    # Update system
    sudo pacman -Syu
    
    # Install Java 11
    sudo pacman -S jdk11-openjdk
    
    # Set JAVA_HOME
    echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk' >> ~/.bashrc
    source ~/.bashrc
    
    # Create kafka user
    sudo useradd -r -s /bin/false kafka
    
    # Create installation directory
    sudo mkdir -p /opt/kafka
    sudo chown kafka:kafka /opt/kafka
    
    # Download and install Kafka
    cd /tmp
    wget https://downloads.apache.org/kafka/2.8.2/kafka_2.13-2.8.2.tgz
    tar -xzf kafka_2.13-2.8.2.tgz
    sudo mv kafka_2.13-2.8.2/* /opt/kafka/
    sudo chown -R kafka:kafka /opt/kafka
    
    # Create data directories
    sudo mkdir -p /var/kafka-logs
    sudo mkdir -p /var/zookeeper
    sudo chown kafka:kafka /var/kafka-logs /var/zookeeper
    
    # Add kafka to PATH
    echo 'export PATH="$PATH:/opt/kafka/bin"' | sudo tee -a /etc/environment

    Alpine Linux

    bash
    # Update package index
    sudo apk update && sudo apk upgrade
    
    # Install Java 11
    sudo apk add openjdk11
    
    # Set JAVA_HOME
    echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk' >> ~/.bashrc
    source ~/.bashrc
    
    # Create kafka user
    sudo adduser -D -s /bin/false kafka
    
    # Create installation directory
    sudo mkdir -p /opt/kafka
    sudo chown kafka:kafka /opt/kafka
    
    # Install required tools
    sudo apk add wget tar
    
    # Download and install Kafka
    cd /tmp
    wget https://downloads.apache.org/kafka/2.8.2/kafka_2.13-2.8.2.tgz
    tar -xzf kafka_2.13-2.8.2.tgz
    sudo mv kafka_2.13-2.8.2/* /opt/kafka/
    sudo chown -R kafka:kafka /opt/kafka
    
    # Create data directories
    sudo mkdir -p /var/kafka-logs
    sudo mkdir -p /var/zookeeper
    sudo chown kafka:kafka /var/kafka-logs /var/zookeeper

    openSUSE Leap/Tumbleweed

    bash
    # Update system
    sudo zypper refresh && sudo zypper update
    
    # Install Java 11
    sudo zypper install -y java-11-openjdk java-11-openjdk-devel
    
    # Set JAVA_HOME
    echo 'export JAVA_HOME=/usr/lib64/jvm/java-11-openjdk' >> ~/.bashrc
    source ~/.bashrc
    
    # Create kafka user
    sudo useradd -r -s /bin/false kafka
    
    # Create installation directory
    sudo mkdir -p /opt/kafka
    sudo chown kafka:kafka /opt/kafka
    
    # Download and install Kafka
    cd /tmp
    wget https://downloads.apache.org/kafka/2.8.2/kafka_2.13-2.8.2.tgz
    tar -xzf kafka_2.13-2.8.2.tgz
    sudo mv kafka_2.13-2.8.2/* /opt/kafka/
    sudo chown -R kafka:kafka /opt/kafka
    
    # Create data directories
    sudo mkdir -p /var/kafka-logs
    sudo mkdir -p /var/zookeeper
    sudo chown kafka:kafka /var/kafka-logs /var/zookeeper

    macOS

    bash
    # Install Homebrew if not already installed
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    # Install Java 11
    brew install openjdk@11
    
    # Set JAVA_HOME
    echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 11)' >> ~/.zshrc
    source ~/.zshrc
    
    # Install Kafka using Homebrew
    brew install kafka
    
    # Or manual installation
    cd /tmp
    wget https://downloads.apache.org/kafka/2.8.2/kafka_2.13-2.8.2.tgz
    tar -xzf kafka_2.13-2.8.2.tgz
    sudo mv kafka_2.13-2.8.2 /usr/local/kafka
    
    # Create data directories
    sudo mkdir -p /usr/local/var/kafka-logs
    sudo mkdir -p /usr/local/var/zookeeper

    FreeBSD

    bash
    # Update ports tree
    sudo portsnap fetch update
    
    # Install Java 11
    sudo pkg install openjdk11
    
    # Set JAVA_HOME
    echo 'export JAVA_HOME=/usr/local/openjdk11' >> ~/.bashrc
    source ~/.bashrc
    
    # Create kafka user
    sudo pw useradd kafka -m
    
    # Download and install Kafka
    cd /tmp
    fetch https://downloads.apache.org/kafka/2.8.2/kafka_2.13-2.8.2.tgz
    tar -xzf kafka_2.13-2.8.2.tgz
    sudo mv kafka_2.13-2.8.2 /usr/local/kafka
    sudo chown -R kafka:kafka /usr/local/kafka
    
    # Create data directories
    sudo mkdir -p /var/kafka-logs
    sudo mkdir -p /var/zookeeper
    sudo chown kafka:kafka /var/kafka-logs /var/zookeeper

    Windows (via WSL2)

    bash
    # Install Windows Subsystem for Linux 2
    # Install Ubuntu 20.04+ from Microsoft Store
    
    # Follow Ubuntu installation steps above
    
    # Alternative: Native Windows installation
    # Download Kafka from Apache website
    # Extract to C:\kafka
    # Install Java 11 from Oracle or OpenJDK
    # Set JAVA_HOME environment variable
    # Use kafka-server-start.bat and zookeeper-server-start.bat

    3. Configuration

    Production-Ready ZooKeeper Configuration

    Create comprehensive ZooKeeper configuration with best practices:

    bash
    # Create ZooKeeper configuration
    sudo tee /opt/kafka/config/zookeeper.properties > /dev/null <<EOF
    # ZooKeeper Server Configuration - Production Settings
    # Data directory for ZooKeeper state
    dataDir=/var/zookeeper
    
    # Client connection port
    clientPort=2181
    
    # Maximum client connections (0 = unlimited, set to 60 for production)
    maxClientCnxns=60
    
    # Admin server configuration
    admin.enableServer=true
    admin.serverPort=8080
    
    # Timing parameters
    tickTime=2000
    initLimit=10
    syncLimit=5
    
    # Purge configuration
    autopurge.snapRetainCount=3
    autopurge.purgeInterval=24
    
    # 4-letter-word commands whitelist
    4lw.commands.whitelist=stat, ruok, conf, isro
    
    # Session tracking
    maxSessionTimeout=40000
    minSessionTimeout=4000
    
    # Ensemble configuration (uncomment for cluster deployment)
    # server.1=zk1.example.com:2888:3888
    # server.2=zk2.example.com:2888:3888
    # server.3=zk3.example.com:2888:3888
    
    # Metrics providers
    metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
    metricsProvider.httpPort=7000
    metricsProvider.exportJvmInfo=true
    
    # Security settings
    serverCnxnFactory=org.apache.zookeeper.server.NettyServerCnxnFactory
    ssl.clientAuth=none
    ssl.quorum.clientAuth=none
    
    # Logging
    zookeeper.log.dir=/var/log/zookeeper
    zookeeper.log.file=zookeeper.log
    zookeeper.log.threshold=INFO
    zookeeper.log.maxfilesize=256MB
    zookeeper.log.maxbackupindex=20
    
    # JVM flags
    jvmFlags=-Xmx1G -Xms1G -XX:+UseG1GC -XX:MaxGCPauseMillis=20
    EOF
    
    # Create ZooKeeper myid file for cluster deployment
    echo "1" | sudo tee /var/zookeeper/myid

    Production Kafka Broker Configuration

    Create comprehensive Kafka broker configuration with security and performance optimizations:

    bash
    # Create production Kafka server configuration
    sudo tee /opt/kafka/config/server.properties > /dev/null <<EOF
    ############################# Server Basics #############################
    # Broker ID - must be unique within cluster
    broker.id=0
    
    # Rack awareness for fault tolerance
    # broker.rack=us-east-1a
    
    # Enable automatic broker ID generation
    # broker.id.generation.enable=true
    # reserved.broker.max.id=1000
    
    ############################# Socket Server Settings #############################
    # Listeners - comma-separated list of URIs
    listeners=PLAINTEXT://:9092,SSL://:9093,SASL_PLAINTEXT://:9094,SASL_SSL://:9095
    
    # Advertised listeners - how clients connect
    advertised.listeners=PLAINTEXT://kafka1.example.com:9092,SSL://kafka1.example.com:9093
    
    # Maps listener names to security protocols
    listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
    
    # Inter-broker communication protocol
    inter.broker.listener.name=PLAINTEXT
    
    # Number of threads handling network requests
    num.network.threads=8
    
    # Number of threads doing disk I/O
    num.io.threads=8
    
    # Send buffer (SO_SNDBUF) for network requests
    socket.send.buffer.bytes=102400
    
    # Receive buffer (SO_RCVBUF) for network requests
    socket.receive.buffer.bytes=102400
    
    # Maximum request size
    socket.request.max.bytes=104857600
    
    # Queue sizes
    queued.max.requests=500
    
    ############################# Log Basics #############################
    # Log directories - comma-separated for multiple disks
    log.dirs=/var/kafka-logs/disk1,/var/kafka-logs/disk2
    
    # Default number of partitions per topic
    num.partitions=3
    
    # Number of threads per data directory for recovery
    num.recovery.threads.per.data.dir=2
    
    # Enable auto-creation of topics
    auto.create.topics.enable=false
    
    # Default replication factor for auto-created topics
    default.replication.factor=3
    
    # Minimum in-sync replicas
    min.insync.replicas=2
    
    ############################# Internal Topic Settings #############################
    # Replication factors for internal topics
    offsets.topic.replication.factor=3
    offsets.topic.num.partitions=50
    offsets.load.buffer.size=5242880
    
    transaction.state.log.replication.factor=3
    transaction.state.log.min.isr=2
    transaction.state.log.num.partitions=50
    
    ############################# Log Flush Policy #############################
    # Flush data to disk
    # log.flush.interval.messages=10000
    log.flush.interval.ms=1000
    log.flush.scheduler.interval.ms=1000
    
    ############################# Log Retention Policy #############################
    # Retention by time (7 days)
    log.retention.hours=168
    
    # Retention by size per partition
    log.retention.bytes=1073741824
    
    # Maximum log segment size
    log.segment.bytes=1073741824
    
    # Check interval for log retention
    log.retention.check.interval.ms=300000
    
    # Enable log cleaner for compacted topics
    log.cleaner.enable=true
    log.cleaner.threads=2
    log.cleaner.io.max.bytes.per.second=10485760
    log.cleaner.dedupe.buffer.size=134217728
    log.cleaner.io.buffer.size=524288
    log.cleaner.min.cleanable.ratio=0.5
    log.cleaner.delete.retention.ms=86400000
    
    ############################# ZooKeeper #############################
    # ZooKeeper connection string
    zookeeper.connect=zk1.example.com:2181,zk2.example.com:2181,zk3.example.com:2181/kafka
    
    # ZooKeeper session timeout
    zookeeper.session.timeout.ms=18000
    
    # ZooKeeper connection timeout
    zookeeper.connection.timeout.ms=18000
    
    # ZooKeeper sync time
    zookeeper.sync.time.ms=2000
    
    ############################# Group Coordinator Settings #############################
    # Rebalance delay for initial consumer group join
    group.initial.rebalance.delay.ms=3000
    
    # Group coordinator threads
    group.coordinator.threads=8
    
    # Offset commit timeout
    offsets.commit.timeout.ms=5000
    offsets.commit.required.acks=-1
    
    ############################# Controller Settings #############################
    # Controller socket timeout
    controller.socket.timeout.ms=30000
    
    # Controller message queue size
    controller.message.queue.size=100
    
    ############################# Compression #############################
    # Compression type for topics
    compression.type=snappy
    
    ############################# Metrics #############################
    # Metrics reporters
    metric.reporters=org.apache.kafka.common.metrics.JmxReporter
    
    # JMX port
    jmx.port=9999
    
    # Metrics recording level
    metrics.recording.level=INFO
    
    # Metrics sample window
    metrics.sample.window.ms=30000
    metrics.num.samples=2
    
    ############################# Quota Configuration #############################
    # Quota window settings
    quota.window.num=11
    quota.window.size.seconds=1
    
    # Producer/Consumer quotas (bytes/sec)
    quota.producer.default=10485760
    quota.consumer.default=10485760
    
    ############################# SSL Configuration #############################
    ssl.keystore.location=/opt/kafka/config/kafka.keystore.jks
    ssl.keystore.password=changeme
    ssl.key.password=changeme
    ssl.truststore.location=/opt/kafka/config/kafka.truststore.jks
    ssl.truststore.password=changeme
    
    # SSL cipher suites
    ssl.cipher.suites=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    
    # SSL protocols
    ssl.enabled.protocols=TLSv1.2,TLSv1.3
    ssl.protocol=TLSv1.3
    
    # SSL endpoint identification
    ssl.endpoint.identification.algorithm=https
    
    ############################# SASL Configuration #############################
    # SASL mechanisms
    sasl.enabled.mechanisms=PLAIN,SCRAM-SHA-256,SCRAM-SHA-512
    
    # SASL inter-broker protocol
    sasl.mechanism.inter.broker.protocol=SCRAM-SHA-512
    
    ############################# Authorization #############################
    # Enable ACLs
    authorizer.class.name=kafka.security.authorizer.AclAuthorizer
    
    # Super users
    super.users=User:admin;User:kafka
    
    # Allow everyone if no ACL found
    allow.everyone.if.no.acl.found=false
    
    ############################# Connection Settings #############################
    # Max connections
    max.connections=1000
    max.connections.per.ip=100
    max.connections.per.ip.overrides=
    
    # Connection idle timeout
    connections.max.idle.ms=600000
    
    ############################# Request Processing #############################
    # Request timeout
    request.timeout.ms=30000
    
    # Fetch settings
    fetch.max.wait.ms=500
    fetch.min.bytes=1
    fetch.max.bytes=57671680
    
    # Maximum fetch size
    replica.fetch.max.bytes=1048576
    replica.fetch.wait.max.ms=500
    replica.fetch.min.bytes=1
    replica.fetch.response.max.bytes=10485760
    
    ############################# Controlled Shutdown #############################
    controlled.shutdown.enable=true
    controlled.shutdown.max.retries=3
    controlled.shutdown.retry.backoff.ms=5000
    
    ############################# Leader Election #############################
    # Unclean leader election
    unclean.leader.election.enable=false
    
    # Leader imbalance settings
    leader.imbalance.check.interval.seconds=300
    leader.imbalance.per.broker.percentage=10
    
    ############################# Feature Flags #############################
    # Enable delete topics
    delete.topic.enable=true
    
    # Enable log message timestamps
    log.message.timestamp.type=CreateTime
    log.message.timestamp.difference.max.ms=9223372036854775807
    
    ############################# Monitoring #############################
    # Enable Kafka metrics
    kafka.metrics.reporters=org.apache.kafka.common.metrics.JmxReporter
    kafka.metrics.polling.interval.secs=10
    EOF

    Production JVM Configuration

    Create optimized JVM settings for production:

    bash
    # Create Kafka environment configuration
    sudo tee /opt/kafka/bin/kafka-server-env.sh > /dev/null <<'EOF'
    #!/bin/bash
    # Kafka Server JVM Performance Settings - Production
    
    # Set Java home
    export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
    
    # Kafka installation directory
    export KAFKA_HOME=/opt/kafka
    
    # Heap settings (adjust based on available RAM)
    # For production: Use 50-75% of available RAM, max 32GB
    export KAFKA_HEAP_OPTS="-Xmx6G -Xms6G"
    
    # G1GC Settings for low latency
    export KAFKA_JVM_PERFORMANCE_OPTS="-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -XX:+AlwaysPreTouch -XX:+UseStringDeduplication -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -Djava.awt.headless=true"
    
    # GC Logging
    export KAFKA_GC_LOG_OPTS="-Xloggc:/var/log/kafka/kafka-gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
    
    # JMX Settings for monitoring
    export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.net.preferIPv4Stack=true"
    
    # Log4J Settings
    export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:${KAFKA_HOME}/config/log4j.properties"
    
    # Set umask for file creation
    umask 077
    EOF
    
    sudo chmod +x /opt/kafka/bin/kafka-server-env.sh
    sudo chown kafka:kafka /opt/kafka/bin/kafka-server-env.sh

    Advanced Log4j2 Configuration

    Configure comprehensive logging with log rotation:

    bash
    # Create advanced Log4j2 configuration
    sudo tee /opt/kafka/config/log4j.properties > /dev/null <<EOF
    # Kafka Log4j Configuration - Production Settings
    
    # Root logger
    log4j.rootLogger=INFO, kafkaAppender, errorAppender
    
    # Kafka logger
    log4j.logger.kafka=INFO, kafkaAppender
    log4j.additivity.kafka=false
    
    # Request logger
    log4j.logger.kafka.request.logger=WARN, requestAppender
    log4j.additivity.kafka.request.logger=false
    
    # Network logger
    log4j.logger.kafka.network.RequestChannel$=WARN, requestAppender
    log4j.additivity.kafka.network.RequestChannel$=false
    
    # Controller logger
    log4j.logger.kafka.controller=INFO, controllerAppender
    log4j.additivity.kafka.controller=false
    
    # Log cleaner logger
    log4j.logger.kafka.log.LogCleaner=INFO, cleanerAppender
    log4j.additivity.kafka.log.LogCleaner=false
    
    # State change logger
    log4j.logger.state.change.logger=INFO, stateChangeAppender
    log4j.additivity.state.change.logger=false
    
    # Authorization logger
    log4j.logger.kafka.authorizer.logger=INFO, authorizerAppender
    log4j.additivity.kafka.authorizer.logger=false
    
    ############################# Appenders #############################
    
    # Main Kafka appender
    log4j.appender.kafkaAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.kafkaAppender.File=/var/log/kafka/server.log
    log4j.appender.kafkaAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.kafkaAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.kafkaAppender.layout.ConversionPattern=[%d] %p [%t] %c{1} - %m%n
    
    # Error appender
    log4j.appender.errorAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.errorAppender.File=/var/log/kafka/error.log
    log4j.appender.errorAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.errorAppender.Threshold=ERROR
    log4j.appender.errorAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.errorAppender.layout.ConversionPattern=[%d] %p [%t] %c{1} - %m%n
    
    # Request appender
    log4j.appender.requestAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.requestAppender.File=/var/log/kafka/kafka-request.log
    log4j.appender.requestAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.requestAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.requestAppender.layout.ConversionPattern=[%d] %p [%t] %c{1} - %m%n
    
    # Controller appender
    log4j.appender.controllerAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.controllerAppender.File=/var/log/kafka/controller.log
    log4j.appender.controllerAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.controllerAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.controllerAppender.layout.ConversionPattern=[%d] %p [%t] %c{1} - %m%n
    
    # Cleaner appender
    log4j.appender.cleanerAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.cleanerAppender.File=/var/log/kafka/log-cleaner.log
    log4j.appender.cleanerAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.cleanerAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.cleanerAppender.layout.ConversionPattern=[%d] %p [%t] %c{1} - %m%n
    
    # State change appender
    log4j.appender.stateChangeAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.stateChangeAppender.File=/var/log/kafka/state-change.log
    log4j.appender.stateChangeAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.stateChangeAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.stateChangeAppender.layout.ConversionPattern=[%d] %p [%t] %c{1} - %m%n
    
    # Authorizer appender
    log4j.appender.authorizerAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.authorizerAppender.File=/var/log/kafka/kafka-authorizer.log
    log4j.appender.authorizerAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.authorizerAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.authorizerAppender.layout.ConversionPattern=[%d] %p [%t] %c{1} - %m%n
    EOF
    
    # Create log directories with proper permissions
    sudo mkdir -p /var/log/kafka /var/log/zookeeper
    sudo chown -R kafka:kafka /var/log/kafka /var/log/zookeeper
    sudo chmod 750 /var/log/kafka /var/log/zookeeper

    Producer Configuration

    Create optimized producer configuration:

    bash
    # Create producer configuration
    sudo tee /opt/kafka/config/producer.properties > /dev/null <<EOF
    # Kafka Producer Configuration - Production Settings
    
    # Broker list
    bootstrap.servers=kafka1.example.com:9092,kafka2.example.com:9092,kafka3.example.com:9092
    
    # Acknowledgment settings
    acks=all
    retries=3
    max.in.flight.requests.per.connection=5
    enable.idempotence=true
    
    # Batching settings
    batch.size=16384
    linger.ms=10
    buffer.memory=33554432
    
    # Compression
    compression.type=snappy
    
    # Timeout settings
    request.timeout.ms=30000
    delivery.timeout.ms=120000
    
    # Serialization
    key.serializer=org.apache.kafka.common.serialization.StringSerializer
    value.serializer=org.apache.kafka.common.serialization.StringSerializer
    
    # Security
    security.protocol=PLAINTEXT
    # security.protocol=SSL
    # ssl.truststore.location=/opt/kafka/config/client.truststore.jks
    # ssl.truststore.password=changeme
    # ssl.keystore.location=/opt/kafka/config/client.keystore.jks
    # ssl.keystore.password=changeme
    # ssl.key.password=changeme
    
    # Metrics
    metrics.recording.level=INFO
    metrics.sample.window.ms=30000
    EOF

    Consumer Configuration

    Create optimized consumer configuration:

    bash
    # Create consumer configuration
    sudo tee /opt/kafka/config/consumer.properties > /dev/null <<EOF
    # Kafka Consumer Configuration - Production Settings
    
    # Broker list
    bootstrap.servers=kafka1.example.com:9092,kafka2.example.com:9092,kafka3.example.com:9092
    
    # Consumer group
    group.id=consumer-group-1
    
    # Offset management
    enable.auto.commit=false
    auto.offset.reset=earliest
    
    # Fetching settings
    fetch.min.bytes=1
    fetch.max.wait.ms=500
    max.partition.fetch.bytes=1048576
    
    # Session management
    session.timeout.ms=30000
    heartbeat.interval.ms=3000
    
    # Deserialization
    key.deserializer=org.apache.kafka.common.serialization.StringDeserializer
    value.deserializer=org.apache.kafka.common.serialization.StringDeserializer
    
    # Security
    security.protocol=PLAINTEXT
    # security.protocol=SSL
    # ssl.truststore.location=/opt/kafka/config/client.truststore.jks
    # ssl.truststore.password=changeme
    # ssl.keystore.location=/opt/kafka/config/client.keystore.jks
    # ssl.keystore.password=changeme
    # ssl.key.password=changeme
    
    # Consumer position
    max.poll.records=500
    max.poll.interval.ms=300000
    
    # Metrics
    metrics.recording.level=INFO
    metrics.sample.window.ms=30000
    EOF

    Kafka Connect Configuration

    Configure Kafka Connect for data integration:

    bash
    # Create Kafka Connect standalone configuration
    sudo tee /opt/kafka/config/connect-standalone.properties > /dev/null <<EOF
    # Kafka Connect Standalone Configuration
    
    # Kafka broker list
    bootstrap.servers=kafka1.example.com:9092,kafka2.example.com:9092,kafka3.example.com:9092
    
    # Converters
    key.converter=org.apache.kafka.connect.json.JsonConverter
    value.converter=org.apache.kafka.connect.json.JsonConverter
    key.converter.schemas.enable=true
    value.converter.schemas.enable=true
    
    # Internal converter for offsets and configs
    internal.key.converter=org.apache.kafka.connect.json.JsonConverter
    internal.value.converter=org.apache.kafka.connect.json.JsonConverter
    internal.key.converter.schemas.enable=false
    internal.value.converter.schemas.enable=false
    
    # Offset storage
    offset.storage.file.filename=/var/kafka-connect/connect.offsets
    offset.flush.interval.ms=10000
    
    # Plugin path
    plugin.path=/opt/kafka/plugins
    
    # REST API
    rest.host.name=0.0.0.0
    rest.port=8083
    rest.advertised.host.name=connect1.example.com
    
    # Security
    # security.protocol=SSL
    # ssl.truststore.location=/opt/kafka/config/connect.truststore.jks
    # ssl.truststore.password=changeme
    # ssl.keystore.location=/opt/kafka/config/connect.keystore.jks
    # ssl.keystore.password=changeme
    # ssl.key.password=changeme
    EOF
    
    # Create Kafka Connect distributed configuration
    sudo tee /opt/kafka/config/connect-distributed.properties > /dev/null <<EOF
    # Kafka Connect Distributed Configuration
    
    # Kafka broker list
    bootstrap.servers=kafka1.example.com:9092,kafka2.example.com:9092,kafka3.example.com:9092
    
    # Group ID
    group.id=connect-cluster
    
    # Converters
    key.converter=org.apache.kafka.connect.json.JsonConverter
    value.converter=org.apache.kafka.connect.json.JsonConverter
    key.converter.schemas.enable=true
    value.converter.schemas.enable=true
    
    # Internal topics for distributed mode
    offset.storage.topic=connect-offsets
    offset.storage.replication.factor=3
    offset.storage.partitions=25
    
    config.storage.topic=connect-configs
    config.storage.replication.factor=3
    
    status.storage.topic=connect-status
    status.storage.replication.factor=3
    status.storage.partitions=5
    
    # Flush intervals
    offset.flush.interval.ms=10000
    
    # Rebalancing
    scheduled.rebalance.max.delay.ms=300000
    
    # Plugin path
    plugin.path=/opt/kafka/plugins
    
    # REST API
    rest.host.name=0.0.0.0
    rest.port=8083
    rest.advertised.host.name=connect1.example.com
    
    # Worker configuration
    connector.client.config.override.policy=All
    
    # Security
    # security.protocol=SSL
    # ssl.truststore.location=/opt/kafka/config/connect.truststore.jks
    # ssl.truststore.password=changeme
    # ssl.keystore.location=/opt/kafka/config/connect.keystore.jks
    # ssl.keystore.password=changeme
    # ssl.key.password=changeme
    EOF
    
    # Create directories for Kafka Connect
    sudo mkdir -p /var/kafka-connect /opt/kafka/plugins
    sudo chown -R kafka:kafka /var/kafka-connect /opt/kafka/plugins

    Schema Registry Configuration (Optional)

    If using Confluent Schema Registry:

    bash
    # Create Schema Registry configuration
    sudo tee /opt/kafka/config/schema-registry.properties > /dev/null <<EOF
    # Schema Registry Configuration
    
    # Listeners
    listeners=http://0.0.0.0:8081
    
    # Kafka broker list
    kafkastore.bootstrap.servers=kafka1.example.com:9092,kafka2.example.com:9092,kafka3.example.com:9092
    
    # Schema topic configuration
    kafkastore.topic=_schemas
    kafkastore.topic.replication.factor=3
    
    # Compatibility
    schema.compatibility.level=backward
    
    # Security
    # kafkastore.security.protocol=SSL
    # kafkastore.ssl.truststore.location=/opt/kafka/config/schema-registry.truststore.jks
    # kafkastore.ssl.truststore.password=changeme
    # kafkastore.ssl.keystore.location=/opt/kafka/config/schema-registry.keystore.jks
    # kafkastore.ssl.keystore.password=changeme
    # kafkastore.ssl.key.password=changeme
    
    # Master election
    master.eligibility=true
    
    # Monitoring
    metrics.jmx.prefix=kafka.schema.registry
    EOF

    Cluster Configuration Script

    Create a script to manage cluster configuration:

    bash
    # Create cluster configuration script
    sudo tee /opt/kafka/bin/configure-cluster.sh > /dev/null <<'EOF'
    #!/bin/bash
    # Kafka Cluster Configuration Script
    
    set -e
    
    # Configuration variables
    KAFKA_HOME="/opt/kafka"
    KAFKA_USER="kafka"
    BROKER_ID=${1:-0}
    ZK_CONNECT=${2:-"localhost:2181"}
    LISTENERS=${3:-"PLAINTEXT://:9092"}
    
    # Function to update broker ID
    update_broker_id() {
        echo "Setting broker.id to ${BROKER_ID}"
        sed -i "s/^broker.id=.*/broker.id=${BROKER_ID}/" ${KAFKA_HOME}/config/server.properties
    }
    
    # Function to update ZooKeeper connection
    update_zk_connect() {
        echo "Setting zookeeper.connect to ${ZK_CONNECT}"
        sed -i "s/^zookeeper.connect=.*/zookeeper.connect=${ZK_CONNECT}/" ${KAFKA_HOME}/config/server.properties
    }
    
    # Function to update listeners
    update_listeners() {
        echo "Setting listeners to ${LISTENERS}"
        sed -i "s/^listeners=.*/listeners=${LISTENERS}/" ${KAFKA_HOME}/config/server.properties
    }
    
    # Function to create required directories
    create_directories() {
        echo "Creating required directories..."
        mkdir -p /var/kafka-logs/disk{1,2}
        mkdir -p /var/log/kafka
        mkdir -p /var/zookeeper
        chown -R ${KAFKA_USER}:${KAFKA_USER} /var/kafka-logs /var/log/kafka /var/zookeeper
    }
    
    # Function to set up SSL certificates
    setup_ssl() {
        echo "Setting up SSL certificates..."
        # Generate keystore and truststore if they don't exist
        if [ ! -f "${KAFKA_HOME}/config/kafka.keystore.jks" ]; then
            keytool -genkey -noprompt \
                    -alias kafka \
                    -dname "CN=kafka.example.com, OU=IT, O=Example, L=City, S=State, C=US" \
                    -keystore ${KAFKA_HOME}/config/kafka.keystore.jks \
                    -storepass changeme \
                    -keypass changeme \
                    -keyalg RSA \
                    -keysize 2048 \
                    -validity 365
        fi
    
        if [ ! -f "${KAFKA_HOME}/config/kafka.truststore.jks" ]; then
            cp ${KAFKA_HOME}/config/kafka.keystore.jks ${KAFKA_HOME}/config/kafka.truststore.jks
        fi
    
        chown ${KAFKA_USER}:${KAFKA_USER} ${KAFKA_HOME}/config/*.jks
        chmod 600 ${KAFKA_HOME}/config/*.jks
    }
    
    # Function to optimize OS settings
    optimize_os() {
        echo "Optimizing OS settings..."
    
        # Increase file descriptors
        echo "* soft nofile 100000" >> /etc/security/limits.conf
        echo "* hard nofile 100000" >> /etc/security/limits.conf
    
        # Optimize network settings
        cat >> /etc/sysctl.conf <<SYSCTL
    # Kafka optimization
    net.core.rmem_max = 134217728
    net.core.wmem_max = 134217728
    net.ipv4.tcp_rmem = 4096 65536 134217728
    net.ipv4.tcp_wmem = 4096 65536 134217728
    net.core.netdev_max_backlog = 5000
    net.ipv4.tcp_max_syn_backlog = 8096
    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_fin_timeout = 30
    vm.swappiness = 1
    vm.dirty_ratio = 5
    vm.dirty_background_ratio = 2
    SYSCTL
    
        sysctl -p
    }
    
    # Main execution
    echo "Configuring Kafka cluster node..."
    
    update_broker_id
    update_zk_connect
    update_listeners
    create_directories
    setup_ssl
    optimize_os
    
    echo "Kafka cluster configuration completed!"
    echo "Broker ID: ${BROKER_ID}"
    echo "ZooKeeper: ${ZK_CONNECT}"
    echo "Listeners: ${LISTENERS}"
    EOF
    
    sudo chmod +x /opt/kafka/bin/configure-cluster.sh
    sudo chown kafka:kafka /opt/kafka/bin/configure-cluster.sh

    4. Service Management

    Systemd Service Files (RHEL/CentOS/Ubuntu/Debian)

    Create ZooKeeper service:

    bash
    sudo tee /etc/systemd/system/zookeeper.service > /dev/null <<EOF
    [Unit]
    Description=Apache ZooKeeper server (Kafka)
    Documentation=http://zookeeper.apache.org
    Requires=network.target remote-fs.target
    After=network.target remote-fs.target
    
    [Service]
    Type=simple
    User=kafka
    Group=kafka
    Environment=JAVA_HOME=/usr/lib/jvm/java-11-openjdk
    ExecStart=/opt/kafka/bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties
    ExecStop=/opt/kafka/bin/zookeeper-server-stop.sh
    Restart=on-abnormal
    TimeoutStopSec=30
    
    [Install]
    WantedBy=multi-user.target
    EOF

    Create Kafka service:

    bash
    sudo tee /etc/systemd/system/kafka.service > /dev/null <<EOF
    [Unit]
    Description=Apache Kafka server
    Documentation=http://kafka.apache.org/documentation.html
    Requires=zookeeper.service
    After=zookeeper.service
    
    [Service]
    Type=simple
    User=kafka
    Group=kafka
    Environment=JAVA_HOME=/usr/lib/jvm/java-11-openjdk
    ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties
    ExecStop=/opt/kafka/bin/kafka-server-stop.sh
    Restart=on-abnormal
    TimeoutStopSec=30
    
    [Install]
    WantedBy=multi-user.target
    EOF

    Enable and start services:

    bash
    # Reload systemd daemon
    sudo systemctl daemon-reload
    
    # Enable services
    sudo systemctl enable zookeeper kafka
    
    # Start services
    sudo systemctl start zookeeper
    sleep 10
    sudo systemctl start kafka
    
    # Check status
    sudo systemctl status zookeeper kafka

    OpenRC Service Files (Alpine Linux)

    Create ZooKeeper service:

    bash
    sudo tee /etc/init.d/zookeeper > /dev/null <<'EOF'
    #!/sbin/openrc-run
    
    name="zookeeper"
    description="Apache ZooKeeper server"
    
    user="kafka"
    group="kafka"
    pidfile="/run/${RC_SVCNAME}.pid"
    command="/opt/kafka/bin/zookeeper-server-start.sh"
    command_args="/opt/kafka/config/zookeeper.properties"
    command_background="true"
    
    depend() {
        need net
        use logger
    }
    
    start_pre() {
        export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
        checkpath --directory --owner ${user}:${group} --mode 0755 \
            /run/${RC_SVCNAME} /var/log/kafka
    }
    EOF
    
    sudo chmod +x /etc/init.d/zookeeper

    Create Kafka service:

    bash
    sudo tee /etc/init.d/kafka > /dev/null <<'EOF'
    #!/sbin/openrc-run
    
    name="kafka"
    description="Apache Kafka server"
    
    user="kafka"
    group="kafka"
    pidfile="/run/${RC_SVCNAME}.pid"
    command="/opt/kafka/bin/kafka-server-start.sh"
    command_args="/opt/kafka/config/server.properties"
    command_background="true"
    
    depend() {
        need net zookeeper
        use logger
    }
    
    start_pre() {
        export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
        checkpath --directory --owner ${user}:${group} --mode 0755 \
            /run/${RC_SVCNAME} /var/log/kafka
    }
    EOF
    
    sudo chmod +x /etc/init.d/kafka
    
    # Enable and start services
    sudo rc-update add zookeeper default
    sudo rc-update add kafka default
    sudo service zookeeper start
    sleep 10
    sudo service kafka start

    macOS (launchd)

    Create ZooKeeper plist:

    bash
    sudo tee /Library/LaunchDaemons/org.apache.zookeeper.plist > /dev/null <<EOF
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.apache.zookeeper</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/kafka/bin/zookeeper-server-start.sh</string>
            <string>/usr/local/kafka/config/zookeeper.properties</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
    </dict>
    </plist>
    EOF

    Create Kafka plist:

    bash
    sudo tee /Library/LaunchDaemons/org.apache.kafka.plist > /dev/null <<EOF
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>org.apache.kafka</string>
        <key>ProgramArguments</key>
        <array>
            <string>/usr/local/kafka/bin/kafka-server-start.sh</string>
            <string>/usr/local/kafka/config/server.properties</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>KeepAlive</key>
        <true/>
    </dict>
    </plist>
    EOF
    
    # Load services
    sudo launchctl load /Library/LaunchDaemons/org.apache.zookeeper.plist
    sudo launchctl load /Library/LaunchDaemons/org.apache.kafka.plist

    FreeBSD (rc.d)

    Create ZooKeeper service:

    bash
    sudo tee /usr/local/etc/rc.d/zookeeper > /dev/null <<'EOF'
    #!/bin/sh
    
    # PROVIDE: zookeeper
    # REQUIRE: LOGIN
    # KEYWORD: shutdown
    
    . /etc/rc.subr
    
    name="zookeeper"
    rcvar="zookeeper_enable"
    
    load_rc_config $name
    
    : ${zookeeper_enable="NO"}
    : ${zookeeper_user="kafka"}
    : ${zookeeper_chdir="/usr/local/kafka"}
    
    pidfile="/var/run/zookeeper.pid"
    command="/usr/sbin/daemon"
    command_args="-p ${pidfile} -T ${name} \
        /usr/local/kafka/bin/zookeeper-server-start.sh \
        /usr/local/kafka/config/zookeeper.properties"
    
    run_rc_command "$1"
    EOF
    
    sudo chmod +x /usr/local/etc/rc.d/zookeeper

    Service Operations

    bash
    # Start services
    sudo systemctl start zookeeper kafka        # systemd
    sudo service zookeeper start && sudo service kafka start  # OpenRC
    sudo launchctl start org.apache.zookeeper   # macOS
    sudo service zookeeper start                # FreeBSD
    
    # Stop services
    sudo systemctl stop kafka zookeeper         # systemd
    sudo service kafka stop && sudo service zookeeper stop    # OpenRC
    sudo launchctl stop org.apache.kafka        # macOS
    sudo service kafka stop                     # FreeBSD
    
    # Restart services
    sudo systemctl restart zookeeper kafka      # systemd
    sudo service zookeeper restart && sudo service kafka restart  # OpenRC
    
    # Check status
    sudo systemctl status kafka                 # systemd
    sudo service kafka status                   # OpenRC
    sudo launchctl list | grep kafka           # macOS
    sudo service kafka status                   # FreeBSD
    
    # View logs
    sudo journalctl -u kafka -f                # systemd
    tail -f /var/log/kafka/server.log          # Direct log file

    5. Troubleshooting

    Common Issues and Solutions

    #### Kafka Won't Start

    Symptom: Kafka service fails to start

    Diagnosis:

    bash
    # Check service status
    sudo systemctl status kafka
    
    # Check logs
    sudo journalctl -u kafka -n 50
    
    # Check if ports are in use
    sudo netstat -tlnp | grep :9092
    sudo lsof -i :9092

    Solutions:

    bash
    # Ensure ZooKeeper is running
    sudo systemctl status zookeeper
    sudo systemctl start zookeeper
    
    # Check disk space
    df -h /var/kafka-logs
    
    # Verify Java installation
    java -version
    echo $JAVA_HOME
    
    # Check file permissions
    sudo chown -R kafka:kafka /opt/kafka /var/kafka-logs /var/zookeeper

    #### OutOfMemoryError

    Symptom: Java heap space errors in logs

    Solution:

    bash
    # Increase heap size in service configuration
    sudo systemctl edit kafka
    
    # Add override configuration
    [Service]
    Environment="KAFKA_HEAP_OPTS=-Xmx2G -Xms2G"
    
    # Restart service
    sudo systemctl daemon-reload
    sudo systemctl restart kafka

    #### Connection Refused Errors

    Symptom: Clients cannot connect to Kafka

    Diagnosis:

    bash
    # Test connectivity
    telnet localhost 9092
    nc -zv localhost 9092
    
    # Check firewall
    sudo firewall-cmd --list-all  # RHEL/CentOS
    sudo ufw status               # Ubuntu/Debian

    Solutions:

    bash
    # Open firewall ports
    sudo firewall-cmd --add-port=9092/tcp --permanent  # RHEL/CentOS
    sudo firewall-cmd --reload
    sudo ufw allow 9092/tcp                            # Ubuntu/Debian
    
    # Check advertised.listeners configuration
    grep advertised.listeners /opt/kafka/config/server.properties

    #### ZooKeeper Connection Issues

    Symptom: Kafka cannot connect to ZooKeeper

    Diagnosis:

    bash
    # Test ZooKeeper connectivity
    echo ruok | nc localhost 2181
    
    # Check ZooKeeper logs
    tail -f /var/log/kafka/zookeeper.log

    Solutions:

    bash
    # Restart ZooKeeper
    sudo systemctl restart zookeeper
    sleep 10
    sudo systemctl restart kafka
    
    # Verify ZooKeeper configuration
    grep clientPort /opt/kafka/config/zookeeper.properties

    #### Disk Space Issues

    Symptom: Kafka stops accepting messages

    Diagnosis:

    bash
    # Check disk usage
    df -h /var/kafka-logs
    du -sh /var/kafka-logs/*

    Solutions:

    bash
    # Clean old log segments
    /opt/kafka/bin/kafka-log-dirs.sh --describe --bootstrap-server localhost:9092
    
    # Adjust retention policy
    /opt/kafka/bin/kafka-configs.sh --zookeeper localhost:2181 \
        --entity-type topics --entity-name your-topic \
        --alter --add-config retention.ms=86400000
    
    # Monitor disk usage
    watch df -h /var/kafka-logs

    Log Analysis

    bash
    # Monitor Kafka logs in real-time
    tail -f /var/log/kafka/server.log
    
    # Search for errors
    grep -i error /var/log/kafka/server.log
    grep -i exception /var/log/kafka/server.log
    
    # Check specific error patterns
    grep "OutOfMemoryError" /var/log/kafka/server.log
    grep "Connection refused" /var/log/kafka/server.log

    Performance Debugging

    bash
    # Check JVM garbage collection
    /opt/kafka/bin/kafka-run-class.sh kafka.tools.JmxTool \
        --object-name java.lang:type=GarbageCollector,name=* \
        --attributes CollectionCount,CollectionTime \
        --jmx-url service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi
    
    # Monitor broker metrics
    /opt/kafka/bin/kafka-run-class.sh kafka.tools.JmxTool \
        --object-name kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec \
        --jmx-url service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi

    6. Security Considerations

    Network Security

    Configure firewall rules:

    bash
    # RHEL/CentOS/Fedora (firewalld)
    sudo firewall-cmd --add-port=9092/tcp --permanent
    sudo firewall-cmd --add-port=2181/tcp --permanent
    sudo firewall-cmd --add-port=9999/tcp --permanent
    sudo firewall-cmd --reload
    
    # Ubuntu/Debian (ufw)
    sudo ufw allow 9092/tcp
    sudo ufw allow 2181/tcp
    sudo ufw allow 9999/tcp
    
    # Restrict access to specific IPs
    sudo firewall-cmd --add-rich-rule="rule family='ipv4' source address='192.168.1.0/24' port protocol='tcp' port='9092' accept" --permanent

    SSL/TLS Encryption

    Generate SSL certificates:

    bash
    # Create certificate authority
    /opt/kafka/bin/kafka-run-class.sh kafka.admin.ConfigCommand \
        --bootstrap-server localhost:9092 \
        --entity-type brokers --entity-default \
        --alter --add-config ssl.keystore.location=/opt/kafka/ssl/kafka.server.keystore.jks
    
    # Create keystore
    keytool -keystore /opt/kafka/ssl/kafka.server.keystore.jks \
        -alias localhost -validity 365 -genkey -keyalg RSA \
        -storepass changeit -keypass changeit \
        -dname "CN=localhost, OU=IT, O=Company, L=City, S=State, C=US"
    
    # Create truststore
    keytool -keystore /opt/kafka/ssl/kafka.server.truststore.jks \
        -alias CARoot -import -file ca-cert \
        -storepass changeit -noprompt
    
    # Update server configuration
    sudo tee -a /opt/kafka/config/server.properties > /dev/null <<EOF
    
    # SSL Configuration
    listeners=PLAINTEXT://localhost:9092,SSL://localhost:9093
    advertised.listeners=PLAINTEXT://localhost:9092,SSL://localhost:9093
    ssl.keystore.location=/opt/kafka/ssl/kafka.server.keystore.jks
    ssl.keystore.password=changeit
    ssl.key.password=changeit
    ssl.truststore.location=/opt/kafka/ssl/kafka.server.truststore.jks
    ssl.truststore.password=changeit
    ssl.client.auth=none
    ssl.enabled.protocols=TLSv1.2,TLSv1.3
    ssl.cipher.suites=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    EOF

    SASL Authentication

    Configure SASL/PLAIN authentication:

    bash
    # Create JAAS configuration
    sudo tee /opt/kafka/config/kafka_server_jaas.conf > /dev/null <<EOF
    KafkaServer {
        org.apache.kafka.common.security.plain.PlainLoginModule required
        username="admin"
        password="admin-secret"
        user_admin="admin-secret"
        user_alice="alice-secret"
        user_bob="bob-secret";
    };
    EOF
    
    # Update server.properties
    sudo tee -a /opt/kafka/config/server.properties > /dev/null <<EOF
    
    # SASL Configuration
    listeners=SASL_PLAINTEXT://localhost:9094
    advertised.listeners=SASL_PLAINTEXT://localhost:9094
    security.inter.broker.protocol=SASL_PLAINTEXT
    sasl.mechanism.inter.broker.protocol=PLAIN
    sasl.enabled.mechanisms=PLAIN
    EOF
    
    # Update service file to include JAAS config
    sudo systemctl edit kafka
    # Add:
    [Service]
    Environment="KAFKA_OPTS=-Djava.security.auth.login.config=/opt/kafka/config/kafka_server_jaas.conf"

    Access Control Lists (ACLs)

    Enable and configure ACLs:

    bash
    # Enable ACLs in server.properties
    echo 'authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer' | \
        sudo tee -a /opt/kafka/config/server.properties
    
    # Create ACL for user alice to read topic test
    /opt/kafka/bin/kafka-acls.sh --authorizer-properties \
        zookeeper.connect=localhost:2181 \
        --add --allow-principal User:alice \
        --operation Read --topic test
    
    # Create ACL for user bob to write to topic test
    /opt/kafka/bin/kafka-acls.sh --authorizer-properties \
        zookeeper.connect=localhost:2181 \
        --add --allow-principal User:bob \
        --operation Write --topic test
    
    # List ACLs
    /opt/kafka/bin/kafka-acls.sh --authorizer-properties \
        zookeeper.connect=localhost:2181 --list

    File System Security

    Set proper file permissions:

    bash
    # Secure Kafka installation
    sudo chmod -R 750 /opt/kafka
    sudo chown -R root:kafka /opt/kafka
    sudo chmod -R 770 /var/kafka-logs /var/zookeeper
    sudo chown -R kafka:kafka /var/kafka-logs /var/zookeeper
    
    # Secure configuration files
    sudo chmod 640 /opt/kafka/config/*.properties
    sudo chown kafka:kafka /opt/kafka/config/*.properties
    
    # Secure SSL certificates
    sudo chmod 600 /opt/kafka/ssl/*
    sudo chown kafka:kafka /opt/kafka/ssl/*

    SELinux Configuration (RHEL/CentOS)

    bash
    # Check SELinux status
    sestatus
    
    # Create custom SELinux policy if needed
    sudo setsebool -P nis_enabled 1
    sudo semanage port -a -t http_port_t -p tcp 9092
    sudo semanage port -a -t http_port_t -p tcp 2181
    
    # Set SELinux contexts
    sudo semanage fcontext -a -t bin_t "/opt/kafka/bin(/.*)?"
    sudo semanage fcontext -a -t etc_t "/opt/kafka/config(/.*)?"
    sudo restorecon -R /opt/kafka

    7. Performance Tuning

    Operating System Tuning

    bash
    # Increase file descriptor limits
    echo 'kafka soft nofile 65536' | sudo tee -a /etc/security/limits.conf
    echo 'kafka hard nofile 65536' | sudo tee -a /etc/security/limits.conf
    
    # Configure kernel parameters
    sudo tee /etc/sysctl.d/99-kafka.conf > /dev/null <<EOF
    # Network tuning
    net.core.rmem_default = 262144
    net.core.rmem_max = 16777216
    net.core.wmem_default = 262144
    net.core.wmem_max = 16777216
    net.core.netdev_max_backlog = 5000
    
    # Memory management
    vm.swappiness = 1
    vm.dirty_background_ratio = 5
    vm.dirty_ratio = 10
    vm.overcommit_memory = 1
    
    # File system
    fs.file-max = 2097152
    EOF
    
    sudo sysctl -p /etc/sysctl.d/99-kafka.conf

    JVM Tuning

    Configure JVM parameters:

    bash
    # Update service environment
    sudo systemctl edit kafka
    
    # Add JVM tuning options
    [Service]
    Environment="KAFKA_HEAP_OPTS=-Xmx4G -Xms4G"
    Environment="KAFKA_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -XX:MaxInlineLevel=15 -Djava.awt.headless=true"
    
    # For large heaps (>8GB), consider:
    Environment="KAFKA_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:G1HeapRegionSize=16m -XX:MinMetaspaceSize=96m -XX:MaxMetaspaceSize=256m"

    Kafka Configuration Tuning

    Optimize broker settings:

    bash
    # Update server.properties for high throughput
    sudo tee -a /opt/kafka/config/server.properties > /dev/null <<EOF
    
    # Network and I/O tuning
    num.network.threads=8
    num.io.threads=16
    socket.send.buffer.bytes=102400
    socket.receive.buffer.bytes=102400
    socket.request.max.bytes=104857600
    num.replica.fetchers=4
    
    # Log segment tuning
    log.segment.bytes=1073741824
    log.index.interval.bytes=4096
    log.flush.interval.messages=10000
    log.flush.interval.ms=1000
    
    # Compression
    compression.type=snappy
    
    # Replica configuration
    replica.fetch.max.bytes=1048576
    replica.fetch.wait.max.ms=500
    
    # Topic configuration
    default.replication.factor=3
    min.insync.replicas=2
    unclean.leader.election.enable=false
    
    # Producer configuration
    batch.size=16384
    linger.ms=5
    buffer.memory=33554432
    
    # Consumer configuration
    fetch.min.bytes=1
    fetch.max.wait.ms=500
    EOF

    Storage Optimization

    Configure storage for optimal performance:

    bash
    # Use separate disks for different components
    # ZooKeeper: Fast SSD for transaction logs
    # Kafka: Multiple disks for log directories
    
    # Update log directory configuration
    sudo sed -i 's|log.dirs=/var/kafka-logs|log.dirs=/data/kafka-logs-1,/data/kafka-logs-2,/data/kafka-logs-3|' \
        /opt/kafka/config/server.properties
    
    # Create RAID0 for multiple disks (if using hardware RAID)
    # Or use individual disks for better parallelism
    
    # Mount options for ext4
    # /dev/sdb1 /data/kafka-logs-1 ext4 defaults,noatime,data=writeback 0 2
    
    # For XFS (recommended for Kafka)
    # /dev/sdb1 /data/kafka-logs-1 xfs defaults,noatime,largeio,inode64,swalloc 0 2

    Monitoring Performance

    bash
    # Monitor key metrics using JMX
    /opt/kafka/bin/kafka-run-class.sh kafka.tools.JmxTool \
        --object-name kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec \
        --jmx-url service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi \
        --reporting-interval 1000
    
    # Monitor disk I/O
    iostat -x 1
    
    # Monitor network
    iftop -i eth0
    
    # Monitor JVM
    /opt/kafka/bin/kafka-run-class.sh kafka.tools.JmxTool \
        --object-name java.lang:type=Memory \
        --attributes HeapMemoryUsage,NonHeapMemoryUsage \
        --jmx-url service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi

    8. Backup and Restore

    Configuration Backup

    bash
    # Create backup directory
    sudo mkdir -p /backup/kafka
    
    # Backup configuration files
    sudo tar -czf /backup/kafka/kafka-config-$(date +%Y%m%d).tar.gz \
        /opt/kafka/config/
    
    # Backup service files
    sudo cp /etc/systemd/system/kafka.service /backup/kafka/
    sudo cp /etc/systemd/system/zookeeper.service /backup/kafka/

    Topic Metadata Backup

    bash
    # Export topic configurations
    /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
        --list > /backup/kafka/topics-$(date +%Y%m%d).txt
    
    # Export topic details
    for topic in $(/opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list); do
        /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
            --describe --topic $topic >> /backup/kafka/topic-details-$(date +%Y%m%d).txt
    done
    
    # Export ACLs if configured
    /opt/kafka/bin/kafka-acls.sh --authorizer-properties \
        zookeeper.connect=localhost:2181 \
        --list > /backup/kafka/acls-$(date +%Y%m%d).txt

    Data Backup Using MirrorMaker

    bash
    # Create MirrorMaker configuration
    cat > /opt/kafka/config/mirror-maker.properties <<EOF
    # Consumer configuration for source cluster
    bootstrap.servers=source-cluster:9092
    group.id=mirror-maker-group
    auto.offset.reset=earliest
    enable.auto.commit=false
    
    # Producer configuration for target cluster
    bootstrap.servers=backup-cluster:9092
    acks=all
    retries=2147483647
    max.in.flight.requests.per.connection=1
    EOF
    
    # Start MirrorMaker for backup
    /opt/kafka/bin/kafka-mirror-maker.sh \
        --consumer.config /opt/kafka/config/consumer.properties \
        --producer.config /opt/kafka/config/producer.properties \
        --whitelist "topic1|topic2|topic3"

    ZooKeeper Backup

    bash
    # Create ZooKeeper snapshot backup
    /opt/kafka/bin/zookeeper-shell.sh localhost:2181 <<< "ls /" > /backup/kafka/zk-snapshot-$(date +%Y%m%d).txt
    
    # Backup ZooKeeper data directory
    sudo tar -czf /backup/kafka/zookeeper-data-$(date +%Y%m%d).tar.gz \
        /var/zookeeper/

    Automated Backup Script

    bash
    sudo tee /opt/kafka/bin/kafka-backup.sh > /dev/null <<'EOF'
    #!/bin/bash
    
    BACKUP_DIR="/backup/kafka"
    DATE=$(date +%Y%m%d_%H%M%S)
    RETENTION_DAYS=30
    
    # Create backup directory
    mkdir -p $BACKUP_DIR
    
    # Backup configurations
    tar -czf $BACKUP_DIR/kafka-config-$DATE.tar.gz /opt/kafka/config/
    
    # Backup topic metadata
    /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
        --list > $BACKUP_DIR/topics-$DATE.txt
    
    # Export topic configurations
    for topic in $(/opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list); do
        /opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 \
            --entity-type topics --entity-name $topic --describe \
            >> $BACKUP_DIR/topic-configs-$DATE.txt
    done
    
    # Backup ZooKeeper data
    tar -czf $BACKUP_DIR/zookeeper-data-$DATE.tar.gz /var/zookeeper/
    
    # Clean old backups
    find $BACKUP_DIR -name "*.tar.gz" -mtime +$RETENTION_DAYS -delete
    find $BACKUP_DIR -name "*.txt" -mtime +$RETENTION_DAYS -delete
    
    echo "Backup completed: $DATE"
    EOF
    
    sudo chmod +x /opt/kafka/bin/kafka-backup.sh

    Restore Procedures

    bash
    # Restore configurations
    sudo tar -xzf /backup/kafka/kafka-config-20231201.tar.gz -C /
    
    # Restore ZooKeeper data (requires service stop)
    sudo systemctl stop kafka zookeeper
    sudo rm -rf /var/zookeeper/*
    sudo tar -xzf /backup/kafka/zookeeper-data-20231201.tar.gz -C /
    sudo chown -R kafka:kafka /var/zookeeper
    sudo systemctl start zookeeper
    sleep 10
    sudo systemctl start kafka
    
    # Recreate topics from backup
    while IFS= read -r topic; do
        /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
            --create --topic $topic --partitions 3 --replication-factor 1
    done < /backup/kafka/topics-20231201.txt

    Schedule Automated Backups

    bash
    # Add cron job for automated backups
    echo "0 2 * * * /opt/kafka/bin/kafka-backup.sh" | sudo crontab -u kafka -

    9. System Requirements

    Minimum Hardware Requirements

    Development Environment:

  • CPU: 2 cores (Intel/AMD x86_64)
  • RAM: 4GB minimum, 8GB recommended
  • Storage: 20GB available space, SSD recommended
  • Network: 100 Mbps connection
  • Production Environment:

  • CPU: 4+ cores (Intel/AMD x86_64), preferably 8+ cores
  • RAM: 8GB minimum, 16GB+ recommended (32GB+ for high throughput)
  • Storage: 100GB+ SSD storage, multiple drives for optimal performance
  • Network: 1 Gbps+ connection with low latency
  • Small Production (< 10K messages/sec):

  • CPU: Intel Xeon or AMD EPYC, 4-8 cores @ 2.5GHz+
  • RAM: 16GB DDR4
  • Storage: 500GB NVMe SSD (single drive acceptable)
  • Network: 1 Gbps Ethernet
  • Medium Production (10K-100K messages/sec):

  • CPU: Intel Xeon or AMD EPYC, 8-16 cores @ 3.0GHz+
  • RAM: 32GB DDR4
  • Storage: 2TB NVMe SSD in RAID1 or multiple individual SSDs
  • Network: 10 Gbps Ethernet
  • Large Production (100K+ messages/sec):

  • CPU: Intel Xeon or AMD EPYC, 16+ cores @ 3.0GHz+
  • RAM: 64GB+ DDR4
  • Storage: Multiple NVMe SSDs (4-8 drives) in individual mount points
  • Network: 10+ Gbps Ethernet with redundancy
  • Operating System Support Matrix

    | OS Family | Versions | Architecture | Status |

    |-----------|----------|--------------|--------|

    | RHEL | 8.x, 9.x | x86_64, ARM64 | Fully Supported |

    | CentOS | Stream 8, Stream 9 | x86_64, ARM64 | Fully Supported |

    | Rocky Linux | 8.x, 9.x | x86_64, ARM64 | Fully Supported |

    | AlmaLinux | 8.x, 9.x | x86_64, ARM64 | Fully Supported |

    | Fedora | 36+, 37+, 38+ | x86_64, ARM64 | Fully Supported |

    | Ubuntu | 20.04 LTS, 22.04 LTS, 24.04 LTS | x86_64, ARM64 | Fully Supported |

    | Debian | 11 (Bullseye), 12 (Bookworm) | x86_64, ARM64 | Fully Supported |

    | Arch Linux | Rolling | x86_64, ARM64 | Fully Supported |

    | Manjaro | 21+, 22+ | x86_64, ARM64 | Fully Supported |

    | EndeavourOS | Current | x86_64, ARM64 | Fully Supported |

    | Alpine Linux | 3.18+, 3.19+ | x86_64, ARM64 | Fully Supported |

    | openSUSE | Leap 15.4+, Tumbleweed | x86_64, ARM64 | Fully Supported |

    | SLES | 15 SP4+ | x86_64, ARM64 | Supported |

    | macOS | 11+, 12+, 13+ | x86_64, ARM64 (M1/M2) | Supported |

    | FreeBSD | 13.x, 14.x | x86_64, ARM64 | Supported |

    | Windows | 10, 11, Server 2019/2022 | x86_64 | Supported (via WSL2) |

    Java Version Requirements

    | Kafka Version | Java Version | Support Status |

    |---------------|-------------|----------------|

    | 2.8.x | Java 8, 11, 17 | Java 11 Recommended |

    | 3.0.x | Java 11, 17 | Java 11+ Required |

    | 3.1.x+ | Java 11, 17, 21 | Java 17 Recommended |

    Network Requirements

    Bandwidth Requirements:

  • Internal: 1 Gbps minimum between brokers
  • Client: 100 Mbps minimum per high-throughput client
  • Management: 10 Mbps for monitoring and administration
  • Latency Requirements:

  • Inter-broker: < 1ms preferred, < 10ms maximum
  • Client-to-broker: < 50ms for optimal performance
  • Cross-datacenter: < 100ms for replication
  • Port Requirements:

  • 9092: Kafka broker (PLAINTEXT)
  • 9093: Kafka broker (SSL)
  • 9094: Kafka broker (SASL_PLAINTEXT)
  • 9095: Kafka broker (SASL_SSL)
  • 2181: ZooKeeper client connections
  • 2888: ZooKeeper peer connections
  • 3888: ZooKeeper leader election
  • 9999: JMX monitoring port
  • Storage Requirements

    File System Support:

  • ext4: Good performance, well-tested
  • XFS: Recommended for large files and high I/O
  • ZFS: Good for data integrity, higher CPU overhead
  • Btrfs: Good features but less mature for production
  • Disk Layout Recommendations:

  • Separate OS and Kafka data partitions
  • Multiple disks for Kafka logs (better than RAID0)
  • Fast SSD for ZooKeeper transaction logs
  • Separate partition for backup storage
  • Capacity Planning:

  • Plan for 3x message retention requirements
  • Account for replication factor (typically 3x storage)
  • Reserve 20% free space for optimal performance
  • Monitor growth and plan expansion
  • 10. Support

    Official Resources

    Apache Kafka Project:

  • Website: https://kafka.apache.org/
  • Documentation: https://kafka.apache.org/documentation/
  • Quick Start: https://kafka.apache.org/quickstart
  • Configuration: https://kafka.apache.org/documentation/#configuration
  • Source Code:

  • GitHub: https://github.com/apache/kafka
  • Apache Git: https://git.apache.org/repos/asf/kafka.git
  • Issue Tracker: https://issues.apache.org/jira/projects/KAFKA
  • Community Support

    Mailing Lists:

  • Users: users@kafka.apache.org
  • Developers: dev@kafka.apache.org
  • Subscribe: Send email to users-subscribe@kafka.apache.org
  • Forums and Chat:

  • Confluent Community: https://forum.confluent.io/
  • Stack Overflow: https://stackoverflow.com/questions/tagged/apache-kafka
  • Apache Slack: https://the-asf.slack.com/messages/kafka/
  • Documentation and Tutorials

    Learning Resources:

  • Confluent Documentation: https://docs.confluent.io/
  • Kafka Tutorials: https://kafka-tutorials.confluent.io/
  • Event Streaming Patterns: https://www.confluent.io/patterns/
  • Books:

  • "Kafka: The Definitive Guide" by Gwen Shapira, Neha Narkhede, Todd Palino
  • "Learning Apache Kafka" by Nishant Garg
  • "Apache Kafka Cookbook" by Saurabh Minni
  • Commercial Support

    Confluent:

  • Confluent Platform: Commercial Kafka distribution
  • Confluent Cloud: Fully managed Kafka service
  • Support: https://www.confluent.io/support/
  • Other Vendors:

  • Red Hat AMQ Streams: Enterprise Kafka on OpenShift
  • IBM Event Streams: Kafka as a service on IBM Cloud
  • Amazon MSK: Managed Streaming for Apache Kafka
  • Monitoring and Management Tools

    Open Source:

  • Kafka Manager (CMAK): https://github.com/yahoo/CMAK
  • Kafdrop: https://github.com/obsidiandynamics/kafdrop
  • Kafka Tool: http://www.kafkatool.com/
  • Commercial:

  • Confluent Control Center: Enterprise monitoring and management
  • Lenses: Kafka development and operations platform
  • Conduktor: Kafka desktop client and admin tool
  • Performance Testing

    Benchmarking Tools:

  • Built-in performance test scripts in /opt/kafka/bin/
  • kafka-producer-perf-test.sh: Producer performance testing
  • kafka-consumer-perf-test.sh: Consumer performance testing
  • kafka-run-class.sh kafka.tools.EndToEndLatency: Latency testing
  • Best Practices Resources

    Confluent Best Practices:

  • https://www.confluent.io/blog/kafka-best-practices/
  • https://www.confluent.io/resources/kafka-best-practices/
  • Apache Kafka Wiki:

  • https://cwiki.apache.org/confluence/display/KAFKA/
  • 11. Contributing

    How to Contribute to This Guide

    We welcome contributions to improve this Apache Kafka installation and configuration guide. Your experience and feedback help make this resource better for the entire community.

    Ways to Contribute:

  • Report issues or inaccuracies in the documentation
  • Suggest improvements for clarity or completeness
  • Add support for additional operating systems or distributions
  • Share troubleshooting solutions for common problems
  • Contribute performance optimization tips
  • Update version-specific information
  • Submitting Changes

    GitHub Repository:

  • URL: https://github.com/howtomgr/apache-kafka
  • Issues: https://github.com/howtomgr/apache-kafka/issues
  • Pull Requests: https://github.com/howtomgr/apache-kafka/pulls
  • Contribution Process:

    1. Fork the Repository

    ```bash

    git clone https://github.com/howtomgr/apache-kafka.git

    cd apache-kafka

    ```

    2. Create a Feature Branch

    ```bash

    git checkout -b feature/your-improvement

    ```

    3. Make Your Changes

  • Follow the existing documentation structure
  • Test all commands and procedures
  • Ensure SPEC 2.0 compliance
  • Update the Version History section
  • 4. Commit Your Changes

    ```bash

    git add .

    git commit -m "Add support for [specific improvement]"

    ```

    5. Submit Pull Request

  • Provide clear description of changes
  • Reference any related issues
  • Include testing information
  • Documentation Standards

    Writing Guidelines:

  • Use clear, concise language appropriate for system administrators
  • Include command examples with expected output
  • Test all procedures on target operating systems
  • Follow the existing format and structure
  • Use proper markdown syntax
  • Content Requirements:

  • All commands must be tested and functional
  • Include error handling and troubleshooting steps
  • Provide security considerations for all configurations
  • Support multiple operating systems where applicable
  • Include performance implications of configuration changes
  • Testing Contributions

    Before Submitting:

  • Test installation procedures on clean systems
  • Verify all commands work as documented
  • Check links and references for accuracy
  • Ensure proper markdown formatting
  • Validate JSON syntax in configuration examples
  • Testing Environments:

  • Use virtual machines or containers for testing
  • Test on multiple operating system distributions
  • Verify both development and production scenarios
  • Document any OS-specific variations
  • Code of Conduct

    Community Standards:

  • Be respectful and constructive in all interactions
  • Focus on improving the documentation quality
  • Provide helpful feedback on others' contributions
  • Follow project guidelines and standards
  • Help maintain a welcoming environment for all contributors
  • Recognition

    Contributors to this guide are acknowledged in the following ways:

  • Listed in the Acknowledgments section
  • Credited in commit history
  • Recognized in project documentation
  • Featured in community highlights
  • Getting Help

    For Contributors:

  • Open an issue for questions about contributing
  • Join community discussions on project forums
  • Contact maintainers for guidance on major changes
  • Review existing pull requests for examples
  • Resources:

  • SPEC 2.0 Guidelines
  • Markdown Style Guide
  • Contributing Guidelines
  • 12. License

    Software License

    Apache Kafka is released under the Apache License 2.0.

  • License: Apache License 2.0
  • SPDX: Apache-2.0
  • OSI Approved: Yes
  • Free Software: Yes
  • Commercial Use: Permitted
  • License Summary:

  • ✅ Commercial use permitted
  • ✅ Modification permitted
  • ✅ Distribution permitted
  • ✅ Patent use permitted
  • ✅ Private use permitted
  • ⚠️ Must include license and copyright notice
  • ⚠️ Must state changes if modifying
  • ❌ Trademark use not permitted
  • ❌ No warranty provided
  • Full License Text:

    The complete Apache License 2.0 text is available at:

  • https://www.apache.org/licenses/LICENSE-2.0
  • https://opensource.org/licenses/Apache-2.0
  • Documentation License

    This installation guide is licensed under the MIT License.

    text
    MIT License
    
    Copyright (c) 2024 HowToMgr
    
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.

    Third-Party Licenses

    Dependencies and Related Software:

    Apache ZooKeeper:

  • License: Apache License 2.0
  • Usage: Cluster coordination (optional in Kafka 2.8+)
  • Website: https://zookeeper.apache.org/
  • OpenJDK:

  • License: GNU General Public License v2 with Classpath Exception
  • Usage: Java runtime environment
  • Website: https://openjdk.java.net/
  • Operating System Components:

  • Various licenses depending on the target operating system
  • All commands and procedures use standard system utilities
  • No proprietary software dependencies
  • Compliance Information

    For Organizations Using This Guide:

  • Guide content is freely usable in commercial environments
  • No attribution required for using installation procedures
  • Consider contributing improvements back to the community
  • Ensure compliance with Kafka's Apache 2.0 license terms
  • For Redistributors:

  • Include this license section when redistributing the guide
  • Maintain copyright notices and attribution
  • Clearly identify any modifications made to the content
  • Respect trademark usage guidelines
  • Warranty Disclaimer

    NO WARRANTY:

    This guide is provided "as is" without warranty of any kind. While every effort has been made to ensure accuracy and completeness, users assume all risks associated with following these instructions.

    LIMITATION OF LIABILITY:

    The authors and contributors shall not be liable for any damages arising from the use of this guide, including but not limited to data loss, system downtime, or security vulnerabilities.

    USER RESPONSIBILITY:

    Users are responsible for:

  • Testing procedures in non-production environments
  • Ensuring compatibility with their specific systems
  • Implementing appropriate security measures
  • Maintaining backups and recovery procedures
  • Staying current with security updates
  • 13. Acknowledgments

    Apache Kafka Community

    Core Contributors:

    We gratefully acknowledge the Apache Kafka community and core contributors who have developed and maintained this exceptional distributed streaming platform:

  • Jun Rao - Co-founder and original architect of Apache Kafka
  • Neha Narkhede - Co-founder and key contributor to Kafka's development
  • Jay Kreps - Co-founder and original creator of Kafka at LinkedIn
  • Guozhang Wang - Kafka Streams lead and core committer
  • Ismael Juma - Long-time committer and community leader
  • Organizations

    Supporting Organizations:

  • Apache Software Foundation - For hosting and governance of the Kafka project
  • Confluent - For continued investment in Kafka development and ecosystem
  • LinkedIn - Original creators and open-source contributors
  • Uber, Netflix, Spotify - Major users providing feedback and contributions
  • Documentation Contributors

    HowToMgr Project:

  • Community Contributors - System administrators and developers who provided feedback
  • Technical Reviewers - Experts who validated procedures and best practices
  • Testers - Volunteers who tested installation procedures across different platforms
  • Reference Sources

    Documentation References:

  • Apache Kafka Official Documentation (https://kafka.apache.org/documentation/)
  • Confluent Documentation (https://docs.confluent.io/)
  • "Kafka: The Definitive Guide" by Gwen Shapira, Neha Narkhede, Todd Palino
  • Various community blog posts and tutorials
  • Technical Resources:

  • Operating system documentation for systemd, OpenRC, and launchd
  • Security best practices from OWASP and industry standards
  • Performance tuning guidance from production deployments
  • SSL/TLS configuration standards from Mozilla Security Guidelines
  • Community Support

    Forums and Communities:

  • Apache Kafka Users Mailing List participants
  • Stack Overflow contributors answering Kafka questions
  • Reddit r/apachekafka community members
  • Confluent Community Forum moderators and participants
  • Special Recognition:

  • Beta Testers - Early users who provided valuable feedback
  • Translators - Contributors helping with internationalization
  • Platform Maintainers - Package maintainers across different operating systems
  • Security Researchers - Professionals who responsibly disclosed security issues
  • Tools and Infrastructure

    Development Tools:

  • GitHub - Repository hosting and collaboration platform
  • Markdown - Documentation formatting language
  • VirtualBox/VMware - Testing environment virtualization
  • Docker - Containerized testing environments
  • Monitoring and Testing:

  • Prometheus/Grafana - Monitoring stack integration examples
  • JMX - Java Management Extensions for metrics collection
  • Various Linux Distributions - For comprehensive compatibility testing
  • Inspiration and Motivation

    Community Values:

    This guide embodies the open-source values of knowledge sharing, collaboration, and community-driven improvement. We are inspired by the countless system administrators and developers who contribute their time and expertise to help others succeed with Apache Kafka deployments.

    Continuous Improvement:

    We acknowledge that this guide is a living document that benefits from ongoing community input, testing, and refinement. Every suggestion, bug report, and contribution helps make this resource more valuable for the entire community.

    Contact Information

    Project Maintainers:

  • HowToMgr Team - https://github.com/howtomgr
  • Community Guidelines - https://howtomgr.github.io/contributing
  • Feedback and Suggestions:

    We welcome feedback, corrections, and suggestions for improving this guide. Please use the GitHub repository issues system or contact the maintainers directly.

    ---

    Thank you to everyone who contributes to making Apache Kafka and its ecosystem accessible to administrators and developers worldwide.

    14. Version History

    Version 1.0.0 (2024-12-23)

    Initial SPEC 2.0 Compliant Release

    New Features:

  • Complete SPEC 2.0 compliant documentation structure
  • Comprehensive multi-OS installation support (RHEL, Debian, Arch, Alpine, SUSE, macOS, FreeBSD, Windows)
  • Production-ready configuration examples
  • Security hardening with SSL/TLS and SASL authentication
  • Performance tuning guidelines and system optimization
  • Comprehensive backup and restore procedures
  • Troubleshooting guide with common issues and solutions
  • Supported Versions:

  • Apache Kafka 2.8.2 (primary focus)
  • Java 11+ support (OpenJDK recommended)
  • ZooKeeper 3.6+ (included with Kafka distribution)
  • Operating System Coverage:

  • RHEL/CentOS/Rocky Linux/AlmaLinux 8.x, 9.x
  • Fedora 36+, 37+, 38+
  • Ubuntu 20.04 LTS, 22.04 LTS, 24.04 LTS
  • Debian 11 (Bullseye), 12 (Bookworm)
  • Arch Linux, Manjaro, EndeavourOS
  • Alpine Linux 3.18+, 3.19+
  • openSUSE Leap 15.4+, Tumbleweed
  • SLES 15 SP4+
  • macOS 11+, 12+, 13+
  • FreeBSD 13.x, 14.x
  • Windows 10/11 (via WSL2)
  • Security Features:

  • SSL/TLS encryption configuration
  • SASL authentication setup
  • Access Control Lists (ACLs)
  • Firewall configuration for major distributions
  • SELinux/AppArmor integration
  • File system permission hardening
  • Service Management:

  • systemd service files (Linux distributions)
  • OpenRC service files (Alpine Linux)
  • launchd configuration (macOS)
  • rc.d scripts (FreeBSD)
  • Service monitoring and health checks
  • Performance Optimizations:

  • JVM tuning parameters
  • Operating system kernel parameter optimization
  • Storage configuration recommendations
  • Network tuning guidelines
  • Monitoring and metrics collection
  • Documentation Standards:

  • All 16 SPEC 2.0 sections implemented
  • Tested procedures across supported platforms
  • Production-ready configurations
  • Security-first approach
  • Community contribution guidelines
  • Upcoming Versions

    Version 1.1.0 (Planned - Q1 2025)

    Proposed Features:

  • Kafka 3.x version support and migration guide
  • KRaft (Kafka Raft) mode configuration (ZooKeeper-free)
  • Container deployment examples (Docker/Podman)
  • Kubernetes operator integration
  • Additional monitoring integrations (Prometheus/Grafana)
  • Schema Registry integration examples
  • Version 1.2.0 (Planned - Q2 2025)

    Proposed Features:

  • Multi-datacenter replication setup
  • Disaster recovery procedures
  • Advanced security configurations
  • Custom connector development guide
  • Kafka Connect distributed mode setup
  • Performance benchmarking tools
  • Version 2.0.0 (Planned - Q4 2025)

    Proposed Features:

  • Major version update alignment with Kafka 4.x
  • Complete KRaft mode transition
  • Enhanced cloud deployment guides
  • Advanced troubleshooting automation
  • Integration with modern observability stacks
  • Updated security standards compliance
  • Change Log

    2024-12-23 - Version 1.0.0:

    text
    Added:
    + Complete SPEC 2.0 documentation structure
    + Multi-OS installation procedures for 13 operating systems
    + SSL/TLS security configuration
    + SASL authentication setup
    + Performance tuning guidelines
    + Backup and restore procedures
    + Service management for multiple init systems
    + Comprehensive troubleshooting guide
    + System requirements matrix
    + Community contribution guidelines
    
    Changed:
    * Restructured from basic README to full production guide
    * Updated configuration examples for current best practices
    * Enhanced security recommendations
    * Improved command examples with better error handling
    
    Security:
    + Added SSL/TLS encryption configuration
    + Implemented SASL authentication procedures
    + Added ACL configuration examples
    + Included firewall configuration for major distributions
    + Added SELinux/AppArmor integration guides
    
    Performance:
    + JVM optimization parameters
    + Operating system tuning recommendations
    + Storage configuration best practices
    + Network optimization guidelines
    + Monitoring and metrics collection setup
    
    Documentation:
    + All sections tested across multiple operating systems
    + Production-ready configuration examples
    + Security-hardened default settings
    + Community feedback integration
    + Professional technical writing standards

    Maintenance Schedule

    Regular Updates:

  • Monthly: Security patches and minor version updates
  • Quarterly: Major version compatibility testing
  • Bi-annually: Complete documentation review and testing
  • Annually: Operating system support matrix updates
  • Update Policy:

  • Security updates are prioritized and released within 48 hours
  • Feature updates follow semantic versioning
  • Backward compatibility maintained within major versions
  • Deprecation notices provided 6 months in advance
  • Contributing to Version History

    Documentation Standards:

    When contributing updates to this guide, please:

  • Update this Version History section with your changes
  • Follow semantic versioning for version numbers
  • Include detailed change descriptions
  • Test all modifications across supported platforms
  • Update the last_updated timestamp in META.json
  • Version Numbering:

  • Major (X.0.0): Breaking changes or major restructuring
  • Minor (X.Y.0): New features, OS support, or significant additions
  • Patch (X.Y.Z): Bug fixes, security updates, or minor improvements
  • 15. Appendices

    Appendix A: Command Reference

    #### Topic Management Commands

    bash
    # Create a topic
    /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
        --create --topic my-topic --partitions 3 --replication-factor 1
    
    # List all topics
    /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --list
    
    # Describe a topic
    /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
        --describe --topic my-topic
    
    # Delete a topic
    /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
        --delete --topic my-topic
    
    # Increase partitions (cannot decrease)
    /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \
        --alter --topic my-topic --partitions 6

    #### Producer Commands

    bash
    # Console producer
    /opt/kafka/bin/kafka-console-producer.sh --bootstrap-server localhost:9092 \
        --topic my-topic
    
    # Producer with key
    /opt/kafka/bin/kafka-console-producer.sh --bootstrap-server localhost:9092 \
        --topic my-topic --property "parse.key=true" --property "key.separator=:"
    
    # Performance test producer
    /opt/kafka/bin/kafka-producer-perf-test.sh --topic my-topic \
        --num-records 10000 --record-size 1024 --throughput 1000 \
        --producer-props bootstrap.servers=localhost:9092

    #### Consumer Commands

    bash
    # Console consumer from latest
    /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 \
        --topic my-topic
    
    # Console consumer from beginning
    /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 \
        --topic my-topic --from-beginning
    
    # Consumer with group
    /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 \
        --topic my-topic --group my-consumer-group
    
    # Performance test consumer
    /opt/kafka/bin/kafka-consumer-perf-test.sh --topic my-topic \
        --messages 10000 --bootstrap-server localhost:9092

    #### Consumer Group Management

    bash
    # List consumer groups
    /opt/kafka/bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
    
    # Describe consumer group
    /opt/kafka/bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 \
        --describe --group my-consumer-group
    
    # Reset consumer group offset to earliest
    /opt/kafka/bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 \
        --group my-consumer-group --reset-offsets --to-earliest --topic my-topic --execute
    
    # Delete consumer group
    /opt/kafka/bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 \
        --delete --group my-consumer-group

    Appendix B: Configuration Templates

    #### Basic Production Server Properties

    properties
    # Basic server configuration
    broker.id=1
    listeners=PLAINTEXT://:9092
    advertised.listeners=PLAINTEXT://your-server-ip:9092
    log.dirs=/var/kafka-logs
    num.partitions=3
    default.replication.factor=3
    min.insync.replicas=2
    
    # Network and I/O
    num.network.threads=8
    num.io.threads=8
    socket.send.buffer.bytes=102400
    socket.receive.buffer.bytes=102400
    socket.request.max.bytes=104857600
    
    # Log configuration
    log.retention.hours=168
    log.segment.bytes=1073741824
    log.retention.check.interval.ms=300000
    log.cleanup.policy=delete
    
    # ZooKeeper
    zookeeper.connect=zk1:2181,zk2:2181,zk3:2181
    zookeeper.connection.timeout.ms=18000
    
    # JMX
    jmx.port=9999
    
    # Compression
    compression.type=snappy
    
    # Transaction settings
    transaction.state.log.replication.factor=3
    transaction.state.log.min.isr=2

    #### SSL Configuration Template

    properties
    # SSL Configuration
    listeners=PLAINTEXT://:9092,SSL://:9093
    advertised.listeners=PLAINTEXT://your-server-ip:9092,SSL://your-server-ip:9093
    
    ssl.keystore.location=/opt/kafka/ssl/kafka.server.keystore.jks
    ssl.keystore.password=changeit
    ssl.key.password=changeit
    ssl.truststore.location=/opt/kafka/ssl/kafka.server.truststore.jks
    ssl.truststore.password=changeit
    
    ssl.client.auth=required
    ssl.enabled.protocols=TLSv1.2,TLSv1.3
    ssl.cipher.suites=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    
    # Security protocol for inter-broker communication
    security.inter.broker.protocol=SSL
    ssl.endpoint.identification.algorithm=HTTPS

    #### SASL Configuration Template

    properties
    # SASL Configuration
    listeners=SASL_PLAINTEXT://:9094,SASL_SSL://:9095
    advertised.listeners=SASL_PLAINTEXT://your-server-ip:9094,SASL_SSL://your-server-ip:9095
    
    security.inter.broker.protocol=SASL_PLAINTEXT
    sasl.mechanism.inter.broker.protocol=PLAIN
    sasl.enabled.mechanisms=PLAIN
    
    # ACL Configuration
    authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
    super.users=User:admin

    Appendix C: Monitoring and Metrics

    #### Key JMX Metrics to Monitor

    bash
    # Broker metrics
    kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec
    kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec
    kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec
    
    # Request metrics
    kafka.network:type=RequestMetrics,name=RequestsPerSec,request=Produce
    kafka.network:type=RequestMetrics,name=RequestsPerSec,request=FetchConsumer
    kafka.network:type=RequestMetrics,name=TotalTimeMs,request=Produce
    
    # Log metrics
    kafka.log:type=LogFlushStats,name=LogFlushRateAndTimeMs
    kafka.log:type=LogSize,name=Size,topic=*,partition=*
    
    # Controller metrics
    kafka.controller:type=KafkaController,name=OfflinePartitionsCount
    kafka.controller:type=KafkaController,name=UnderReplicatedPartitions

    #### Prometheus Configuration Example

    yaml
    # prometheus.yml
    global:
      scrape_interval: 15s
    
    scrape_configs:
      - job_name: 'kafka'
        static_configs:
          - targets: ['localhost:9999']
        metrics_path: /metrics
        scrape_interval: 30s

    #### Grafana Dashboard Queries

    promql
    # Message rate
    rate(kafka_server_brokertopicmetrics_messagesin_total[5m])
    
    # Byte rate
    rate(kafka_server_brokertopicmetrics_bytesin_total[5m])
    
    # Request latency
    kafka_network_requestmetrics_totaltimems{request="Produce",quantile="0.95"}
    
    # Partition count
    kafka_server_replicamanager_partitioncount

    Appendix D: Security Checklists

    #### Pre-Production Security Checklist

    Network Security:

  • [ ] Firewall configured to allow only necessary ports
  • [ ] SSL/TLS encryption enabled for all client connections
  • [ ] Inter-broker communication secured
  • [ ] Network segmentation implemented
  • [ ] VPN or private network for management access
  • Authentication and Authorization:

  • [ ] SASL authentication configured
  • [ ] Default passwords changed
  • [ ] User accounts created with minimal privileges
  • [ ] ACLs configured for topic access
  • [ ] Admin access restricted
  • File System Security:

  • [ ] Kafka runs as non-root user
  • [ ] File permissions properly configured (750/640)
  • [ ] Log directories secured
  • [ ] SSL certificate files protected (600 permissions)
  • [ ] Backup files encrypted
  • System Security:

  • [ ] Operating system updates applied
  • [ ] SELinux/AppArmor configured
  • [ ] Unnecessary services disabled
  • [ ] Log monitoring configured
  • [ ] Intrusion detection system deployed
  • Monitoring and Auditing:

  • [ ] JMX access secured
  • [ ] Log aggregation configured
  • [ ] Security event monitoring
  • [ ] Regular security assessments scheduled
  • [ ] Incident response procedures documented
  • Appendix E: Performance Tuning Checklist

    #### System-Level Optimizations

    Operating System:

  • [ ] File descriptor limits increased (65536+)
  • [ ] Kernel parameters optimized (vm.swappiness, net.core.*)
  • [ ] Disk scheduler configured (deadline/mq-deadline for SSDs)
  • [ ] CPU governor set to performance
  • [ ] NUMA topology considered
  • Storage:

  • [ ] Separate disks for OS, Kafka logs, and ZooKeeper
  • [ ] XFS or ext4 file system used
  • [ ] noatime mount option enabled
  • [ ] SSD storage for high-throughput workloads
  • [ ] Multiple log directories configured
  • Network:

  • [ ] Network interface card (NIC) tuning
  • [ ] TCP buffer sizes optimized
  • [ ] Network interrupt handling optimized
  • [ ] Bandwidth monitoring configured
  • [ ] Latency monitoring implemented
  • #### JVM-Level Optimizations

    Memory Management:

  • [ ] Heap size configured (6-8GB typical)
  • [ ] G1GC garbage collector enabled
  • [ ] GC logging enabled
  • [ ] Off-heap caching considered
  • [ ] Memory monitoring configured
  • JVM Parameters:

    bash
    -server
    -XX:+UseG1GC
    -XX:MaxGCPauseMillis=20
    -XX:InitiatingHeapOccupancyPercent=35
    -XX:+ExplicitGCInvokesConcurrent
    -XX:MaxInlineLevel=15
    -Djava.awt.headless=true

    #### Kafka-Level Optimizations

    Broker Configuration:

  • [ ] Number of network/IO threads optimized
  • [ ] Socket buffer sizes configured
  • [ ] Compression enabled (snappy/lz4)
  • [ ] Batch size optimized
  • [ ] Replication settings tuned
  • Topic Configuration:

  • [ ] Partition count optimized for parallelism
  • [ ] Replication factor set appropriately
  • [ ] Retention policies configured
  • [ ] Cleanup policies optimized
  • [ ] Segment size configured
  • Appendix F: Disaster Recovery Procedures

    #### Backup Verification Checklist

    Regular Verification Tasks:

  • [ ] Configuration backups tested monthly
  • [ ] Topic metadata backup verified
  • [ ] ZooKeeper snapshot integrity checked
  • [ ] SSL certificate expiration monitored
  • [ ] Recovery procedures tested quarterly
  • Recovery Testing:

  • [ ] Full cluster recovery tested
  • [ ] Single node replacement verified
  • [ ] Data consistency validation
  • [ ] Client reconnection testing
  • [ ] Performance baseline verification
  • #### Emergency Contact Information

    Escalation Matrix:

    text
    Level 1: System Administrator
    Level 2: Kafka Platform Team
    Level 3: Senior Architect
    Level 4: External Support (Confluent/Vendor)

    Communication Channels:

  • Primary: Incident management system
  • Secondary: Team chat/Slack
  • Emergency: Phone/SMS alerts
  • Status: Public status page updates
  • This completes the SPEC 2.0 compliant Apache Kafka installation and configuration guide. The document now contains all 16 required sections with comprehensive coverage of installation, configuration, security, performance, and operational procedures across multiple operating systems and deployment scenarios.