Introductory learning of spring-kafka (1): installation and startup of kafka

table of Contents

1. The choice of software version

Two, install zookeeper

1 download zookeeper

2 configure zookeeper

3 start zookeeper

Three, install kafka

1 download kafka

2 placement kafka

3 start kafka

Four, test


1. The choice of software version

Two, install zookeeper

Kafka uses Zookeeper to save cluster metadata and consumer information.

1 download zookeeper

http://archive.apache.org/dist/zookeeper/

Select version 3.4.6, unzip it to the D:\java directory

2 configure zookeeper

Modify zoo_sample.cfg to zoo.cfg in D:\java\zookeeper-3.4.6\conf

Create 2 folders and add configuration in D:\java\zookeeper-3.4.6

dataDir=D:\\java\\zookeeper-3.4.6\\data

dataLogDir=D:\\java\\zookeeper-3.4.6\\log

Note: The folder separator must be "\\"

3 start zookeeper

Then cmd enters the D:\java\zookeeper-3.4.6\bin directory

Execute zkServer.cmd to start Zookeeper

Successfully started

 

Three, install kafka

 

1 download kafka

http://kafka.apache.org/downloads.html
select version 2.12-2.1.1, unzip it to the D:\java directory

2 placement kafka

Create a new kafka-logs folder in the D:\java\kafka_2.12-2.1.1 directory

Enter the config directory and modify the log.dirs path in service.properties log.dirs=D:\\java\\kafka_2.12-2.1.1\\kafka-logs
Note: The folder separator must be "\\"

3 start kafka

In the D:\java\kafka_2.12-2.1.1 directory run_kafka.bat file, add the following content
.\bin\windows\kafka-server-start.bat .\config\server.properties

Start kafka and report an error:'wmic' is not an internal or external command, nor is it a runnable program.
Reason: Check whether the variable value under the variable name Path in the environment variable has the following information, if not, add it:
%SystemRoot%;%SystemRoot% \system32;%SystemRoot%\System32\Wbem

Successfully started

Four, test

Enter D:\java\kafka_2.12-2.1.1\bin\windows directory

1Create topic

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

2 Create a producer

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

3 create consumers

kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

4 Enter "a" at the black window of the producer, and receive "a" at the black window of the consumer

Note: Do not close the producer and consumer windows

 

Reference book: "The Definitive Guide to Kafka" 

Guess you like

Origin blog.csdn.net/cs373616511/article/details/106032147