I. System environment

Windows10 JDK version: 1.8 kafka version: 2.12-2.5.0 [server version – client version]

Check whether it has been installed

no

Three, installation steps

This version of Kafka comes with ZooKeeper, so you don’t need to download zooKeeper

1, download

Address:http://kafka.apache.org/downloads.htmlTo find the version shown in the figure:

2, decompression

The decompression address and folder name are customizedD:\devp, rename to kafka:

3. Edit the configuration file

Change the directory to D: devp kafka config

  • Properties Open the server.properties file and configure the following properties:
Set the data store location
log.dirs=D:/devp/kafka/logs/kafka-data
Set the zooKeeper connection address and port
zookeeper.connect=localhost:2181
Copy the code
  • Properties Open the zookeeper.properties file and configure the following properties:
Set the data store location
dataDir=D:/devp/kafka/logs/zk-data
Set the zooKeeper port
clientPort=2181
Copy the code

Start Kafka

  • Start Kafka in the following sequence: Start ZooKeeper and then Kafka
  • The default kafka port is 9092

1. Start ZooKeeper

Go to the installation directory D:\devp\kafka. From there, open the CMD window and run the following command:

.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties

After the startup is successful, the console displays the following information:

2. Start Kafka

Go to the installation directory D:\devp\kafka, open the CMD window from this directory, and run the following command:.\bin\ Windows \kafka-server-start.bat.\config\server.properties After successful startup, the console displays the following information:

3. Startup script description

After downloading the startup script, remove the.txt suffix from the file and find the following location:



Locate the zooKeeper data store and Kafka data store specified in the configuration file.

  • Note the backslash\Separate paths;
  • If garbled characters occur after startup, edit the script, save the file, and set the encoding toANSI(Encoding type unique to Windows system, the system will automatically convert this type of encoding into other local codes according to the country information, such as GB2312 of China).

Script code

Bat kafka one-click start script

@echoOff :: GB2312 code :: @ is the best option for script creationechoOff indicates the command that is not executed :: Sets the source path and destination path. To use this variable, wrap it with a pair of % ::setSRC_PATH=.. \1\
set ZK_PATH=D:\devp\kafka\zkdata
set KAFKA_PATH=D:\devp\kafka\data

@echo on
@echo############ Deleting temporary ZooKeeper files ############ ::delDelete file /q without confirmation:del /q %SRC_PATH%a.pdf
:: rdDelete directory (including empty directory) /s directory and its subdirectory /q without confirmationrem rd /s /q %ZK_PATH%
@echo off
@echo############ Temporary ZooKeeper files have been deleted ############ @echo on
@echo############ deleting kafka temporary files ############ ::delDelete file /q without confirmation:del /q %SRC_PATH%a.pdf
:: rdDelete directory (including empty directory) /s directory and its subdirectory /q without confirmationrem rd /s /q %KAFKA_PATH%
@echo off
@echo############ Temporary kafka files have been deleted ############
rem TIMEOUT /T 5: : @echo############ Start the bw-xxl-job task scheduling service ############ ::start cmd /k "cd /d E:\tool\booway-xxl-job && titleBw-xxl-job Task scheduling service && Java -jar xxl-job-admin-2.2.0.jar"


@echo############ Start the Kafka service ############start cmd /k "cd /d D:\devp\kafka && titleZookeeper service &&.\bin\ Windows \ Zookeeper-server -start.bat .\config\zookeeper.properties"
TIMEOUT /T 10
start cmd /k "cd /d D:\devp\kafka && titleKafka service &&.bin \ Windows \kafka-server-start.bat .\config\server.properties"
exit
Copy the code