Installing Kafka on Ubuntu
Absolutely! Here’s a blog about installing Kafka on Ubuntu, incorporating insights from provided feedback and aiming for an easy-to-follow style:
Installing Apache Kafka on Ubuntu: A Step-by-Step Guide
Apache Kafka is a powerful distributed streaming platform for building real-time data pipelines, messaging systems, and more. Ubuntu offers a great foundation to set up your Kafka installation if you’re working with large-scale data in a Linux environment. Let’s walk through the process step by step.
Prerequisites
- Ubuntu Server: I’ll assume you have an Ubuntu server ready (Ubuntu 20.04 or later is recommended).
- Java: Kafka is built on Java, so you’ll need a compatible Java Development Kit (JDK) installed. OpenJDK 11 is a good choice.
- Basic Command-Line Familiarity: You’ll use the command line for this process.
Step 1: Install Java
- Update your package lists:
- Bash
- sudo apt update
- Use code.
- content_copy
- Install OpenJDK 11:
- Bash
- sudo apt install default-JDK
- Use code
- content_copy
- Verify installation:
Bash
java -version
Use code
content_copy
Step 2: Create a Kafka User
- It’s best practice to run Kafka under a dedicated user for security. Create one:
- Bash
- sudo adduser Kafka
- Use code
- content_copy
- Give this user a password when prompted.
Step 3: Download Kafka Binaries
- Visit the Apache Kafka downloads page:
- Choose the latest stable release and find the link for the binary tarball (.tgz file).
- Right-click on the link and select “Copy Link Address”.
- On your Ubuntu server, use wget to download:
- Bash
- wget <paste the copied download link>
- Use code.
- content_copy
Step 4: Extract and Organize
- Extract the downloaded file:
- Bash
- tar -xzf kafka_*.tgz
- Use code
- content_copy
- (Replace the filename with the actual downloaded file name)
- Move the extracted directory to /opt:
- Bash
- sudo mv kafka_* /opt/kafka
- Use code
- content_copy
Step 5: Configure Kafka
- Navigate to Kafka’s configuration directory:
- Bash
- cd /opt/kafka/config/
- Use code
- content_copy
- Edit server.properties (use your preferred editor like Nano or Vim):
- Bash
- sudo nano server.properties
- Use code
- content_copy
- Modify at least the following settings:
- listeners: Your server’s IP address and port (e.g., listeners=PLAINTEXT://192.168.1.10:9092)
- log. Dirs: Where Kafka will store data (e.g., /var/log/kafka) – create this directory if needed.
Step 6: Systemd Unit Files
- Create systemd service files for both Zookeeper (Kafka’s dependency) and Kafka:
- Bash
- sudo nano /etc/systemd/system/zookeeper.service
- sudo nano /etc/systemd/system/kafka.service
- Use code
- content_copy
- Paste the respective configurations (find templates on resources like DigitalOcean tutorials).
Step 7: Start and Test
- Reload system:
- Bash
- sudo systemctl daemon-reload
- Use code
- content_copy
- Start Zookeeper:
- Bash
- sudo systemctl start zookeeper
- Use code
- content_copy
- Start Kafka:
- Bash
- sudo systemctl start kafka
- Use code
- content_copy
- Verify both are running:
- Bash
- sudo systemctl status zookeeper
- sudo systemctl status kafka
- Use code
- content_copy
Congratulations! You’ve successfully installed Kafka on Ubuntu.
Conclusion:
Unogeeks is the No.1 IT Training Institute for Apache kafka Training. Anyone Disagree? Please drop in a comment
You can check out our other latest blogs on Apache Kafka here – Apache kafka Blogs
You can check out our Best In Class Apache Kafka Details here – Apache kafka Training
Follow & Connect with us:
———————————-
For Training inquiries:
Call/Whatsapp: +91 73960 33555
Mail us at: info@unogeeks.com
Our Website ➜ https://unogeeks.com
Follow us:
Instagram: https://www.instagram.com/unogeeks
Facebook: https://www.facebook.com/UnogeeksSoftwareTrainingInstitute
Twitter: https://twitter.com/unogeek