Skip to main content

Install Apache Kafka on Ubuntu 20.04

 

https://kafka.apache.org/powered-by

Introduction

Apache Kafka is an open-source, distributed message broker based on Scala and Java. It's used as a publish-subscribe messaging system; when a producer publishes a message, it's broadcast, and subscribers can get notified and process the information. It can handle large volumes of real-time data and event streaming pipelines with higher throughput than popular message brokers like ActiveMQ and RabbitMQ. In addition, it's highly scalable and fault-tolerant.

Apache Kafka uses Apache Zookeeper to keep track of its cluster node's status, topics, partitions, and so on. Apache ZooKeeper is an open-source project built for centralized services. It provides configuration information, naming, synchronization and group services for large clusters in a distributed systems.

This article explains how to install Apache Kafka on Ubuntu 20.04 server.

Prerequisites

  • Ubuntu 20.04 Server.
  • Create a non-root user with sudo access.

1. Install Java

Update system package list.

$ sudo apt update

Install Java 11 AWS Corretto .

$ wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add - 
$ sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
$ sudo apt-get update; sudo apt-get install -y java-11-amazon-corretto-jdk

Verify the installation.

$ java --version

2. Install Apache Kafka

Download Apache Kafka source files. To find the latest version of this software, visit the official download website.

$ wget https://dlcdn.apache.org/kafka/3.1.0/kafka_2.12-3.1.0.tgz

Create an installation directory /usr/local/kafka-server.

$ sudo mkdir /usr/local/kafka-server

Extract the downloaded files.

$ sudo tar -xzf kafka_2.12-3.1.0.tgz

Move the extracted files to the installation directory.

$ sudo mv kafka_2.12-3.1.0/* /usr/local/kafka-server

For Apache Kafka and Apache Zookeeper to run as daemons, create systemd files for both of them.

Creating systemd file for Apache Zookeeper.

$ sudo nano /etc/systemd/system/zookeeper.service

Add the following lines of code to the file, save and close the file.

[Unit]

Description=Apache Zookeeper Server

Requires=network.target remote-fs.target

After=network.target remote-fs.target

[Service]

Type=simple

ExecStart=/usr/local/kafka-server/bin/zookeeper-server-start.sh /usr/local/kafka-server/config/zookeeper.properties

ExecStop=/usr/local/kafka-server/bin/zookeeper-server-stop.sh

Restart=on-abnormal

[Install]

WantedBy=multi-user.target

Creating systemd file for Apache Kafka.

$ sudo nano /etc/systemd/system/kafka.service

Add the following lines of code to the file, save and close the file.

[Unit]

Description=Apache Kafka Server

Documentation=http://kafka.apache.org/documentation.html

Requires=zookeeper.service

After=zookeeper.service

[Service]

Type=simple

Environment="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64"

ExecStart=/usr/local/kafka-server/bin/kafka-server-start.sh /usr/local/kafka-server/config/server.properties

ExecStop=/usr/local/kafka-server/bin/kafka-server-stop.sh

Restart=on-abnormal

[Install]

WantedBy=multi-user.target

Reload the systemd daemons to apply the changes.

$ sudo systemctl daemon-reload

Start and enable the Apache Zookeeper service for startup on system boot.

$ sudo systemctl enable --now zookeeper.service

Start and enable the Apache Kafka service for startup on system boot.

$ sudo systemctl enable --now kafka.service

Verify the status of both Apache Zookeeper and Apache Kafka services.

$ sudo systemctl status kafka zookeeper

3. Install Cluster Manager for Apache Kafka (CMAK).

CMAK is a graphical management tool for Apache Kafka clusters. It provides the user with various tools to avoid using the CLI interface.

Clone the CMAK repository from GitHub.

$ git clone https://github.com/yahoo/CMAK.git

Edit the CMAK configuration file.

$ sudo nano CMAK/conf/application.conf

Change the value of cmak.zkhosts as follows.

cmak.zkhosts="localhost:2181"

Change to the CMAK directory.

$ cd CMAK

Create a zip file used for deploying the application.

$ ./sbt clean dist

Change into CMAK/target/universal directory.

$ cd target/universal

Install unzip package.

$ sudo apt install unzip -y

Extract the created zip file.

$ sudo unzip cmak-3.0.0.5.zip

Change to the extracted directory.

$ cd cmak-3.0.0.5

Execute the CMAK binary to start the service.

$ sudo bin/cmak

4. Access CMAK Web Interface

Open your web browser and access the CMAK web interface using the URL http://ServerIP:9000. For example:

http://192.0.2.10:9000


Conclusion

You have installed Apache Kafka and Apache Zookeeper on your server. You can now access the CMAK dashboard and add a Kafka cluster.

Popular posts from this blog

Nền tảng Dữ Liệu Khách Hàng (Customer Data Platforms - CDP) là gì? - Một cách giải thích đơn giản Ngày nay, Thu nhập dữ liệu khách hàng là một trong những hoạt động “sót còn” để phát triển doanh nghiệp. Do đó, để giúp doanh nghiệp giải đáp bài toán phức tạp liên quan đến vấn đề này, một giải pháp mới được hình thành: Nền tảng dữ liệu khách hàng (Customer Data Platform - CDP). Vậy chính xác nền tảng dữ liệu khách hàng (CDP) là gì? Không cần sử dụng các biệt ngữ phần mềm và thuật ngữ kỹ thuật, chúng ta có thể hiểu đơn giản Nền tảng Dữ Liệu Khách Hàng như sau: 1, Nền Tảng Dữ Liệu Khách Hàng (CDP) là gì? “ A Customer Data Platform is a packaged software that consolidates customer data from multiple sources and creates a persistent, unified and real-time customer database easily accessible by other systems. ” Có thể dịch đơn giản như sau: “Nền Tảng Dữ Liệu Khách Hàng (CDP) là một loại phần mềm tạo ra một cơ sở dữ liệu khách hàng liên tục, thống nhất, bền vững có thể truy cập được từ các hệ
Nền tảng dữ liệu khách hàng (CDPs) sẽ ngày càng trở nên quan trọng trong những năm tới. Quy mô thị trường nền tảng dữ liệu khách hàng sẽ tăng từ 3,5 tỷ USD vào năm 2021 lên 15,3 tỷ USD vào năm 2026, với Tốc độ tăng trưởng hàng năm tổng hợp (CAGR) là 34,6% trong giai đoạn dự báo. https://www.marketsandmarkets.com/Market-Reports/customer-data-platform-market-94223554.html Mặc dù thuật ngữ này được sử dụng đầu tiên vào năm 2013 để mô tả chung một số loại hệ thống tiếp thị có chung khả năng xây dựng cơ sở dữ liệu khách hàng thống nhất, nhưng vẫn có một số quan niệm sai lầm về Nền tảng dữ liệu khách hàng là gì.  Do đó, chúng ta sẽ làm rõ 9 quan điểm sai lầm về CDP ngay bên dưới bên dưới 1) CDP giống như một CRM ? Mặc dù phần mềm CDP và CRM có một vài điểm tương đồng nhưng xét về mục đích và chức năng chính thì chúng có sự khác biệt rõ ràng. CRM lưu trữ dữ liệu của những khách hàng đã từng tương tác với doanh nghiệp trước đó. Đó có thể là dữ liệu về khách hàng tiềm năng, khách hàng hiện tại,
Leo CDP System Architecture  Server requirements must have Internet and have the installed Linux operating system  If you have from 100,000 to 1 million profiles Need 5 servers: 1) Data Observer: 2 servers (4 CPUs, 8 GB RAM, 20 GB SSD disk) 2) Database: 1 server (8 CPUs, 16 GB RAM, 500 GB SSD disk) 3) Data Processor: 1 server (4 CPUs, 8 GB RAM, 120 GB SSD disk) 4) Admin Dashboard: 1 server (4 CPUs, 8 GB RAM, 40 GB SSD disk) If you have from  1 million to 2 million profiles Need  10 servers: 1) Data Observer: 4 servers (4 CPUs, 8 GB RAM, 20 GB SSD disk) 2) Database: 2 servers (8 CPUs, 16 GB RAM, 500 GB SSD disk) 3) Data Processor: 2 servers (4 CPUs, 8 GB RAM, 120 GB SSD disk) 4) Admin Dashboard: 2 servers (4 CPUs, 8 GB RAM, 40 GB SSD disk) F.A.Q. in Vietnamese: 1. LEO CDP có giá bao nhiêu, mua như thế nào ? Miễn phí  cho mọi mục đích Ghi chú: 1. Profile là một data record các thông tin cá nhân và dữ liệu hành vi của khách hàng Định danh một profile bằng email hoặc số điện thoại hoặc số