Apache Kafka

An open-source distributed event streaming platform for high-performance data pipelines.

Important Files and Directories

  • Main Kafka installation directory: /opt/kafka
  • Kafka broker configuration file: /opt/kafka/config/server.properties
  • Kafka log directory (broker logs, retained events): /opt/kafka/logs
  • Kafka binaries and CLI tools (kafka-topics.sh, kafka-console-producer.sh, etc.): /opt/kafka/bin
  • Systemd service unit for managing Kafka: /etc/systemd/system/kafka.service

Kafka Service

sudo systemctl restart kafka
sudo systemctl enable kafka
sudo systemctl status kafka

Create a Topic

/opt/kafka/bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092

Check topic details:

/opt/kafka/bin/kafka-topics.sh --describe --topic quickstart-events --bootstrap-server localhost:9092

Produce Events (Messages)

/opt/kafka/bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092

Type one event per line.

Press Ctrl+C to exit.

Consume Events

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

Press Ctrl+C to stop reading.

Events can be consumed multiple times by multiple clients.

Logs & Troubleshooting

  • Kafka logs: /opt/kafka/logs
  • Systemd journal: sudo journalctl -u kafka -f
  • Ensure ports 9092 (broker) and 9093 (controller) are open.

Application Details