Kafka-2.2.1 source environment construction on windows

1. View CDH's kafka->host->components

Confirm that the Kafka version corresponding to the CDH version is 2.2.1

2. Go to kafka official website to download the 2.2.1 src file of kafka
3. Unzip the .tgz file
4. Enter the decompressed file plus, open cmd here
5. Enter the command in the terminal (may need to connect to the external network)
gradle wrapper
gradlew jar
gradlew idea
6. Use idea import project

Choose gradle

7. Modify the zookeeper address of config/server.properties
8.windows build zookeeper

Download apache-zookeeper-3.6.2-bin.zip and unzip

Modify zoo_example.cfg of zk\conf to zoo.cfg

Run zk\bin\zkServer.cmd

9. Run core\src\main\scala\kafka\Kafka.scala in Idea
10.Edit Configurations:

VM options:

-Dlog4j.configuration=file:D:\workspace\project_IDEA\KAFKA\kafka-2.2.1-src\config\log4j.properties

Program arguments:

config/server.properties
11. Replace the build.gradle file
12. Import dependencies

File->Project Structure->Modules->
kafka-2.2.1-src/core/main->
dependencies->右上角加号->Insert picture description here

13.build to compile the project
13. Run kafka.scala and run kafka service successfully!
14. Create topic
kafka-topics.bat --zookeeper 127.0.0.1:2181 --create --replication-factor 1 --partitions 1 --topic a1
15. Log output

Modify log4j.properties:

log4j.appender.kafkaAppender.File=D:\\workspace\\share

Guess you like

Origin blog.csdn.net/weixin_44224087/article/details/108870987