Build Kafka under Windows and send and receive messages through the command window

Source: Internet
Author: User

Reference URL:

70154278

Prerequisites: The Windows environment requires a JDK installation

1. Download Kafka, you can download kafka,http://kafka.apache.org/through the official website, currently using version kafka_2.11-1.1.0.tgz (ASC, SHA512)

2. since Kafka relies on zookeeper, it is also necessary to download zookeeper, which can be downloaded via the official website http://zookeeper.apache.org/

3. Installing Zookeeper

    • After extracting the compressed package, go to the bin directory and start Zkserver.bat

Note: The default address of the ZOOKEEPER is: localhost:2181; environment variable needs to be configured: New Zookeeper_home, path to ZOOKEEPER installation directory, add%zookeeper_home%\conf to Path

Start Zookeeper success

4. Installing Kafka

    • Unzip the Kafka compressed package, where Zookeeper's address in Kafka profile Config\server.properties is also default to localhost:2181
    • Select Kafka Unzip the file, shift+ the right mouse button, select "Open command Line window (W) Here", open the command line, enter the following command to start the Kafka:

Bin\windows\kafka-server-start.bat config\server.properties

    • After the boot is complete, select Kafka unzip the file, shift+ the right mouse button, select "Open command Line window (W) Here", open the command line, enter the following command, create a topic theme

Bin\windows\kafka-topics.bat--create--zookeeper localhost:2181--replication-factor 1--partitions 1--topic test

    • Use the following command to view a list of topics created: Bin\windows\kafka-topics.bat--list--zookeeper localhost:2181

    • To start a producer, you can send a message:

Bin\windows\kafka-console-producer.bat--broker-list localhost:9092--topic test

After executing the above command, you can enter text freely in the console

    • Then select Kafka Unzip the file, shift+ the right mouse button, select "Open command Line window (W)", open the command line, enter the following command to start the consumer

Bin\windows\kafka-console-consumer.bat--zookeeper localhost:2181--topic test--from-beginning

Can see that consumers can successfully receive messages

Build Kafka under Windows and send and receive messages through the command window

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.