(Windows) Kafka cluster deployment

1.The operating environment of kafka requires JDK

        https://www.oracle.com/cn/java/technologies/javase-jdk15-downloads.html

 

2. Download the non-source version of Kafka

        http://kafka.apache.org/downloads

        

 

3. Now kafka comes with zookeeper and does not need to be downloaded separately (for separate download and deployment please see the zookeeper cluster deployment posted earlier), the zookeeper configuration file is: kafka_2.13-2.7.0-2\config\zookeeper.properties

(This article uses a single machine to configure zookeeper . Note that dataDir and clientPort cannot be the same, and the IP and firewall must be changed for multiple machines )

        

        

        

 

        Create a new zookeeper-snapshots folder (same as dataDir) in the kafka home directory, and create a myid file in this directory in the cluster mode . The content of the myid file has only one line, which corresponds to the id in the server.id , which represents the id of the zk process, and the content can only be a number between 1-255. The myid content of the three servers in the above example are 1, 2, and 3 respectively .

 

4. The kafka server configuration file is: kafka_2.13-2.7.0-2\config\server.properties

(This article uses a stand-alone configuration of kafka, note that broker.id , port, dataDir, log.dir cannot be the same)

        

        

        

 

5. Producer configuration file: kafka_2.13-2.7.0-2\config\producer.properties

Consumer configuration file: kafka_2.13-2.7.0-2\config\consumer.properties

Add to the kafka server list separately (note that it is not the zookeeper server list), make no mistake about the IP and port

        

 

6. The server is configured, start zookeeper

        Start zookeeper1

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\zookeeper-server-start.bat D:\apache\kafka_2.13-2.7.0\config\zookeeper.properties

        Start zookeeper2

                cd D:\apache\kafka_2.13-2.7.0-2\bin\windows

                .\zookeeper-server-start.bat D:\apache\kafka_2.13-2.7.0-2\config\zookeeper.properties

        Start zookeeper3

                cd D:\apache\kafka_2.13-2.7.0-3\bin\windows

                .\zookeeper-server-start.bat D:\apache\kafka_2.13-2.7.0-3\config\zookeeper.properties

 

7. Start kafka ( failure to start, empty kafka-datas, kafka-logs, logs, zookeeper-snapshots/version-2 folder content and try again)

        Start kafka1

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\kafka-server-start.bat D:\apache\kafka_2.13-2.7.0\config\server.properties

        Start kafka2

                cd D:\apache\kafka_2.13-2.7.0-2\bin\windows

                .\kafka-server-start.bat D:\apache\kafka_2.13-2.7.0-2\config\server.properties

        Start kafka3

                cd D:\apache\kafka_2.13-2.7.0-3\bin\windows

                .\kafka-server-start.bat D:\apache\kafka_2.13-2.7.0-3\config\server.properties

 

8. Other commands (note that the production and consumption of the new version is through bootstrap-server instead of zookeeper )

        Create theme

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\kafka-topics.bat --create --zookeeper localhost:2181,localhost:2182,localhost:2183 --replication-factor 1 --partitions 1 --topic TestTopic1

 

        View topic

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\kafka-topics.bat --zookeeper localhost:2181,localhost:2182,localhost:2183 --describe --topic TestTopic1

 

        Topic list

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\kafka-topics.bat --zookeeper localhost:2181,localhost:2182,localhost:2183 --list

 

        Producer

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\kafka-console-producer.bat --bootstrap-server localhost:9092,localhost:9093,localhost:9094 --topic TestTopic1

        (The old version is broker-list , and the new version is bootstrap-server )

 

        consumer

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\kafka-console-consumer.bat --bootstrap-server localhost:9092,localhost:9093,localhost:9094 --topic TestTopic1 --from-beginning

 

        Delete topic ( marked for deletion, not actually deleted )

                cd D:\apache\kafka_2.13-2.7.0\bin\windows

                .\kafka-topics --zookeeper localhost:2181,localhost:2182,localhost:2183 --delete --topic TestTopic1

 

9. Kafka interface management tool: kafka tool

        https://www.kafkatool.com/download.html

 

 

Guess you like

Origin blog.csdn.net/tianxiefenxiang/article/details/113107268