Home > System Tutorial > LINUX > Quick guide to install Kafka on Linux

Quick guide to install Kafka on Linux

WBOY
Release: 2024-02-01 08:32:05
Original
1197 people have browsed it

Title: Linux Kafka Installation Tutorial: Getting Started Quickly

Text:

1. Preface

Apache Kafka is a distributed publish-subscribe messaging system that can handle large amounts of data and provide high throughput, low latency, and high reliability. Kafka is widely used in log collection, data analysis, stream processing and other fields.

2. Installation preparation

  1. Operating system: Linux (Ubuntu 18.04 or higher is recommended)
  2. Java: JDK 8 or Higher version
  3. ZooKeeper: 3.4.14 or higher version
  4. Kafka: 2.11 or higher version

3. Install ZooKeeper

  1. Download ZooKeeper: Download the ZooKeeper binary package from the Apache official website.
  2. Decompress ZooKeeper: Extract the downloaded binary package to the specified directory.
  3. Configure ZooKeeper: Find the conf/zoo.cfg file in the decompressed ZooKeeper directory, and modify the following configuration:

    • dataDir=/path/to/zookeeper/data: ZooKeeper data directory
    • clientPort=2181: ZooKeeper client port
  4. start ZooKeeper: Run the following command to start ZooKeeper:
bin/zkServer.sh start
Copy after login

4. Install Kafka

  1. Download Kafka: Download the Kafka binary package from the Apache official website.
  2. Decompress Kafka: Extract the downloaded binary package to the specified directory.
  3. Configure Kafka: Find the config/server.properties file in the decompressed Kafka directory, and modify the following configuration:

    • broker.id=0: Kafka broker ID
    • zookeeper.connect=localhost:2181: ZooKeeper connection address
    • log.dirs=/path /to/kafka/logs: Kafka log directory
  4. Start Kafka: Run the following command to start Kafka:
bin/kafka-server-start.sh config/server.properties
Copy after login

5. Create Topic

  1. Open the Kafka command line tool: Run the following command to open the Kafka command line tool:
bin/kafka-console-producer.sh --topic my-topic
Copy after login
  1. Create a topic: In the Kafka command line tool Enter the following command to create a topic:
create my-topic --replication-factor 1 --partitions 1
Copy after login

6. Send a message

  1. Enter the following command in the Kafka command line tool to send a message:
send my-topic hello world
Copy after login

7. Receive messages

  1. Open another Kafka command line tool: Run the following command to open another Kafka command line tool:
bin/kafka-console-consumer.sh --topic my-topic --from-beginning
Copy after login
  1. Receive messages: Received messages will be displayed in the Kafka command line tool.

8. Stop Kafka

  1. Run the following command to stop Kafka:
bin/kafka-server-stop.sh
Copy after login
  1. Run the following command Stop ZooKeeper:
bin/zkServer.sh stop
Copy after login

9. Summary

Through the above steps, you have successfully installed Kafka on Linux. Now you can start using Kafka to process your data.

The above is the detailed content of Quick guide to install Kafka on Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template