Home  >  Article  >  Java  >  A step-by-step guide to learning to use Kafka version queries

A step-by-step guide to learning to use Kafka version queries

王林
王林Original
2024-02-01 08:05:06918browse

A step-by-step guide to learning to use Kafka version queries

1. Install Kafka

  • Download and install Apache Kafka on your server.
  • Decompress the Kafka archive file.
  • Set environment variablesKAFKA_HOME is the Kafka installation directory.

2. Start ZooKeeper

  • ZooKeeper is a dependency of Kafka, so it must be started before starting Kafka.
  • Open a command line terminal and navigate to the $KAFKA_HOME/bin directory.
  • Run the following command to start ZooKeeper:
./zookeeper-server-start.sh config/zookeeper.properties

3. Start the Kafka server

  • Open a command line terminal and navigate to $KAFKA_HOME/bin Directory.
  • Run the following command to start the Kafka server:
./kafka-server-start.sh config/server.properties

4. Create a topic

  • A topic is a logical grouping of data in Kafka .
  • To create a theme, open a command line terminal and navigate to the $KAFKA_HOME/bin directory.
  • Run the following command to create a topic:
./kafka-topics.sh --create --topic my-topic --partitions 1 --replication-factor 1

5. Send a message

  • To send a message to the topic, open the command Run Terminal and navigate to the $KAFKA_HOME/bin directory.
  • Run the following command to send a message:
./kafka-console-producer.sh --topic my-topic --message "Hello, world!"

6. Consume messages

  • To consume messages from a topic, open the command Run Terminal and navigate to the $KAFKA_HOME/bin directory.
  • Run the following command to consume messages:
./kafka-console-consumer.sh --topic my-topic --from-beginning

7. Query the version

  • To query the version of the Kafka server, please open Command line terminal and navigate to the $KAFKA_HOME/bin directory.
  • Run the following command to query the version:
./kafka-version.sh

Sample output

kafka-version.sh:
 version: 2.8.0
 kafka-version: 2.8.0
 kafka-storage: 2.8.0
 kafka-clients: 2.8.0
 kafka-streams: 2.8.0
 kafka-connect: 2.8.0
 kafka-admin: 2.8.0
 kafka-tools: 2.8.0

The above is the detailed content of A step-by-step guide to learning to use Kafka version queries. 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