To install Apache Kafka on Ubuntu 20.04, follow these general steps:
1. Install Java
Kafka requires Java to run. You can install OpenJDK by running:
sudo apt update
sudo apt install default-jdk
2. Download Kafka
Visit the Apache Kafka downloads page to get the latest version. Use wget to download it:
wget https://downloads.apache.org/kafka/2.8.0/kafka_2.13-2.8.0.tgz
3. Extract Kafka
Extract the downloaded Kafka archive:
tar -xzf kafka_2.13-2.8.0.tgz
4. Move Kafka
Move the extracted Kafka directory to /usr/local/kafka:
sudo mv kafka_2.13-2.8.0 /usr/local/kafka
5. Start Kafka Server
Kafka requires Zookeeper to run. Start Zookeeper and Kafka server using the following commands:
/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
6. Create Kafka Topics
You can create a topic using:
/usr/local/kafka/bin/kafka-topics.sh --create --topic test --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1
7. Run Producer and Consumer
Test your setup by running a producer and consumer:
/usr/local/kafka/bin/kafka-console-producer.sh --topic test --bootstrap-server localhost:9092
/usr/local/kafka/bin/kafka-console-consumer.sh --topic test --from-beginning --bootstrap-server localhost:9092
These steps provide a basic setup for Apache Kafka on Ubuntu 20.04. For more detailed instructions, you might want to refer to other resources or tutorials specific to your needs.







