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:
1. Prerequisites
Hardware Requirements
Software Requirements
Network Requirements
User Permissions
2. Installation
RHEL/CentOS/Rocky Linux/AlmaLinux/Fedora
# 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
# 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
# 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
# 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
# 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
# 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
# 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)
# 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:
# 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:
# 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:
# 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:
# 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:
# 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:
# 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:
# 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:
# 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:
# 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:
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:
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:
# 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:
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:
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:
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:
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:
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
# 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:
# 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:
# 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:
# 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:
# Test connectivity
telnet localhost 9092
nc -zv localhost 9092
# Check firewall
sudo firewall-cmd --list-all # RHEL/CentOS
sudo ufw status # Ubuntu/Debian
Solutions:
# 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:
# Test ZooKeeper connectivity
echo ruok | nc localhost 2181
# Check ZooKeeper logs
tail -f /var/log/kafka/zookeeper.log
Solutions:
# 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:
# Check disk usage
df -h /var/kafka-logs
du -sh /var/kafka-logs/*
Solutions:
# 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
# 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
# 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:
# 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:
# 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:
# 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:
# 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:
# 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)
# 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
# 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:
# 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:
# 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:
# 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
# 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
# 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
# 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
# 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
# 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
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
# 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
# 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:
Production Environment:
Recommended Hardware Specifications
Small Production (< 10K messages/sec):
Medium Production (10K-100K messages/sec):
Large Production (100K+ messages/sec):
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:
Latency Requirements:
Port Requirements:
Storage Requirements
File System Support:
Disk Layout Recommendations:
Capacity Planning:
10. Support
Official Resources
Apache Kafka Project:
Source Code:
Community Support
Mailing Lists:
Forums and Chat:
Documentation and Tutorials
Learning Resources:
Books:
Commercial Support
Confluent:
Other Vendors:
Monitoring and Management Tools
Open Source:
Commercial:
Performance Testing
Benchmarking Tools:
/opt/kafka/bin/Best Practices Resources
Confluent Best Practices:
Apache Kafka Wiki:
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:
Submitting Changes
GitHub Repository:
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
4. Commit Your Changes
```bash
git add .
git commit -m "Add support for [specific improvement]"
```
5. Submit Pull Request
Documentation Standards
Writing Guidelines:
Content Requirements:
Testing Contributions
Before Submitting:
Testing Environments:
Code of Conduct
Community Standards:
Recognition
Contributors to this guide are acknowledged in the following ways:
Getting Help
For Contributors:
Resources:
12. License
Software License
Apache Kafka is released under the Apache License 2.0.
License Summary:
Full License Text:
The complete Apache License 2.0 text is available at:
Documentation License
This installation guide is licensed under the MIT License.
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:
OpenJDK:
Operating System Components:
Compliance Information
For Organizations Using This Guide:
For Redistributors:
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:
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:
Organizations
Supporting Organizations:
Documentation Contributors
HowToMgr Project:
Reference Sources
Documentation References:
Technical Resources:
Community Support
Forums and Communities:
Special Recognition:
Tools and Infrastructure
Development Tools:
Monitoring and 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:
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:
Supported Versions:
Operating System Coverage:
Security Features:
Service Management:
Performance Optimizations:
Documentation Standards:
Upcoming Versions
Version 1.1.0 (Planned - Q1 2025)
Proposed Features:
Version 1.2.0 (Planned - Q2 2025)
Proposed Features:
Version 2.0.0 (Planned - Q4 2025)
Proposed Features:
Change Log
2024-12-23 - Version 1.0.0:
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:
Update Policy:
Contributing to Version History
Documentation Standards:
When contributing updates to this guide, please:
Version Numbering:
15. Appendices
Appendix A: Command Reference
#### Topic Management Commands
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
# 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:
Authentication and Authorization:
File System Security:
System Security:
Monitoring and Auditing:
Appendix E: Performance Tuning Checklist
#### System-Level Optimizations
Operating System:
Storage:
Network:
#### JVM-Level Optimizations
Memory Management:
JVM Parameters:
-server
-XX:+UseG1GC
-XX:MaxGCPauseMillis=20
-XX:InitiatingHeapOccupancyPercent=35
-XX:+ExplicitGCInvokesConcurrent
-XX:MaxInlineLevel=15
-Djava.awt.headless=true
#### Kafka-Level Optimizations
Broker Configuration:
Topic Configuration:
Appendix F: Disaster Recovery Procedures
#### Backup Verification Checklist
Regular Verification Tasks:
Recovery Testing:
#### Emergency Contact Information
Escalation Matrix:
Level 1: System Administrator
Level 2: Kafka Platform Team
Level 3: Senior Architect
Level 4: External Support (Confluent/Vendor)
Communication Channels:
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.