Home >System Tutorial >LINUX >Share detailed tutorials on installing Kafka under Linux

Share detailed tutorials on installing Kafka under Linux

王林
王林Original
2024-01-31 15:01:091023browse

How to install Kafka under Linux: Complete tutorial sharing

1. Prerequisites

  • Operating system: Ubuntu 18.04 or Higher version
  • Java: JDK 8 or higher
  • Apache Kafka: 2.13 or higher
  • ZooKeeper: 3.4.14 or higher

2. Install Java

sudo apt-get update
sudo apt-get install openjdk-8-jdk

3. Install Apache Kafka

wget https://dlcdn.apache.org/kafka/2.13/kafka_2.13-3.3.1.tgz
tar -xvzf kafka_2.13-3.3.1.tgz

4. Install ZooKeeper

wget https://dlcdn.apache.org/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
tar -xvzf zookeeper-3.4.14.tar.gz

5. Configure Kafka

cd kafka_2.13-3.3.1
cp config/server.properties config/server.properties.orig
vim config/server.properties

Modify the following configuration:

broker.id=0
listeners=PLAINTEXT://localhost:9092
zookeeper.connect=localhost:2181

6. Configure ZooKeeper

cd zookeeper-3.4.14
cp conf/zoo.cfg conf/zoo.cfg.orig
vim conf/zoo.cfg

Modify the following configuration:

dataDir=/tmp/zookeeper
clientPort=2181

7. Start ZooKeeper

cd zookeeper-3.4.14
bin/zkServer.sh start

8. Start Kafka

cd kafka_2.13-3.3.1
bin/kafka-server-start.sh config/server.properties

9. Create Topic

bin/kafka-topics.sh --create --topic my-topic --partitions 1 --replication-factor 1

10. Send message

bin/kafka-console-producer.sh --topic my-topic --message "Hello, world!"

11. Consume message

bin/kafka-console-consumer.sh --topic my-topic --from-beginning

12. Stop Kafka

bin/kafka-server-stop.sh

13. Stop ZooKeeper

bin/zkServer.sh stop

The above is the detailed content of Share detailed tutorials on installing Kafka under Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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