Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and test kafka

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to install test kafka, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.

Install kafka on server1 and server2

Cd / tmp

Tar-xzf kafka_2.12-2.4.1.tgz

Mv kafka_2.12-2.4.1 kafka

Cd kafka

Start ZooKeeper in server1

. / bin/zookeeper-server-start.sh. / config/zookeeper.properties &

Start kafka in server1

. / bin/kafka-server-start.sh. / config/server.properties &

Check to see if zookeeper and kafka services have been started

Ps-ef | grep kafka

Create a topic called "test" with only one partition and one copy:

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

You can view the created topic with list. Currently, 1 topic has been created.

. / bin/kafka-topics.sh-list-zookeeper localhost:2181

Test

Open a terminal on server1 to send messages. Run producer and enter some messages in the console, which will be sent to the server

. / bin/kafka-console-producer.sh-broker-list localhost:9092-topic test

Open another terminal to open consumer, you can read the message just sent and output.

. / bin/kafka-console-consumer.sh-- bootstrap-server localhost:9092-- topic test-- from-beginning

Send a message on server2. Run producer and enter some messages in the console, which will be sent to the server

/ tmp/kafka/bin/kafka-console-producer.sh-broker-list server1:9092-topic test

Open another terminal on server1 and open consumer, and you can read the message just sent and output it.

/ tmp/kafka/bin/kafka-console-consumer.sh-bootstrap-server localhost:9092-topic test-from-beginning

The above is how to install test kafka. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report