Install Kafka on windows (transfer)

Transfer from https://www.cnblogs.com/lnice/p/9668750.html
KAFKA running environment installation on WINDOWS

  1. Install JDK
    1.1 installation file: http://www.oracle.com/technetwork/java/javase/downloads/index.html Download JDK
    1.2 After installation, you need to add the following environment variables (right click "My Computer" -> " Advanced System Settings" -> "Environment Variables"):

JAVA_HOME: C:\Program Files\Java\jdk1.8.0_171 (jdk installation path)
Path: Add "; %JAVA_HOME%\bin" after the existing value
1.3 Open cmd and run "java -version" to view the current system Java version of:

Insert picture description here

  1. Installing ZOOKEEPER
    Kafka relies on Zookeeper to run, so we need to install and run Zookeeper before running Kafka

2.1 Download the installation file: http://zookeeper.apache.org/releases.html
2.2 Unzip the file
2.3 Open zookeeper-3.4.13\conf, rename zoo_sample.cfg to zoo.cfg
2.4 Open zoo from a text editor. cfg
2.5 Change the value of dataDir to "./zookeeper-3.4.13/data"
2.6 Add the following system variables:
ZOOKEEPER_HOME: C:\Users\localadmin\CODE\zookeeper-3.4.13 (zookeeper directory)
Path: In the existing Add ";%ZOOKEEPER_HOME%\bin;" after the value of
2.7 Run Zookeeper: Open cmd and execute zkserver
Insert picture description here

Don't close the cmd window

  1. Install and run KAFKA
    3.1 Download the installation file: http://kafka.apache.org/downloads.html
    3.2 Unzip the file
    3.3 Open kafka_2.11-2.0.0\config
    3.4 Open server.properties from a text editor
    3.5 Log. Change the value of dirs to "./logs"
    3.6 Open cmd
    3.7 Enter the kafka file directory: cd C:\Users\localadmin\CODE\kafka_2.11-2.0.0 (kafka directory)
    3.8 Enter and execute: .\bin\windows \kafka-server-start.bat .\config\server.properties
    Insert picture description here

Don't close the cmd window

  1. Create TOPICS
    4.1 Open cmd and enter cd C:\Users\localadmin\CODE\kafka_2.11-2.0.0\bin\windows
    4.2 Create a topic: kafka-topics.bat --create --zookeeper localhost:2181 --replication -factor 1 --partitions 1 --topic test
    Insert picture description here

  2. 打开一个PRODUCER:
    cd C:\Users\localadmin\CODE\kafka_2.11-2.0.0\bin\windows
    kafka-console-producer.bat --broker-list localhost:9092 --topic test

  3. 打开一个CONSUMER:
    cd C:\Users\localadmin\CODE\kafka_2.11-2.0.0\bin\windows
    kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

  4. test:

Insert picture description here

The copyright of this article belongs to the author and the blog garden, welcome to reprint, but you need to keep this statement without the author's consent, and give the original link in an obvious place on the article page.

Guess you like

Origin blog.csdn.net/weixin_42094764/article/details/113886573