Home > System Tutorial > LINUX > Detailed steps to install Kafka on CentOS7

Detailed steps to install Kafka on CentOS7

WBOY
Release: 2023-12-29 17:19:32
forward
716 people have browsed it

Introduction

Kafka is a high-throughput distributed publish-subscribe messaging system that can replace traditional message queues for decoupling data processing, caching unprocessed messages, etc. It also has higher throughput and supports partitioning, multiple copies, Redundant, so it is widely used in large-scale message data processing applications

Kafka supports Java and multiple other language clients, and can be used in conjunction with Hadoop, Storm, Spark and other big data tools.

This tutorial mainly introduces the installation and use of Kafka on Centos 7, including functional verification and simple configuration of the cluster.

Install JDK

Kafka uses Zookeeper to save relevant configuration information. Kafka and Zookeeper rely on the Java operating environment. Download the JDK installation package from the Oracle website, unzip and install:

$tar zxvf jdk-8u65-linux-x64.tar.gz
$mv jdk1.8.0_65 java
Copy after login

Set Java environment variables:

JAVA_HOME=/opt/java
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH
Copy after login

You can also choose yum install to install and set the environment variables accordingly.

Install Kafka

Download the Kafka installation package from the official website, unzip and install: Official website address: //m.sbmmt.com/link/dcf531edc9b229acfe0f4b87e1e278dd

tar zxvf kafka_2.11-0.8.2.2.tgz
mv kafka_2.11-0.8.2.2 kafka
cd kafka
Copy after login

Functional Verification

1. Start Zookeeper Use the script in the installation package to start a single-node Zookeeper instance:

bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
Copy after login

2. Start the Kafka service. Use kafka-server-start.sh to start the kafka service:

bin/kafka-server-start.sh config/server.properties
Copy after login

3. Create topic Use kafka-topics.sh to create a topic test with a single partition and a single copy:

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Copy after login

View topic:

bin/kafka-topics.sh --list --zookeeper localhost:2181
test
Copy after login

4. Generate messages Use kafka-console-producer.sh to send messages:

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test 
Hello world!
Copy after login

5. Consume messages Use kafka-console-consumer.sh to receive messages and print them on the terminal:

bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
Copy after login

The messages generated by the producer and the messages consumed by the consumer are synchronized.

Detailed steps to install Kafka on CentOS7

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

Related labels:
source:jb51.net
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