In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Windows how to install and run Apache Kafka, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Download the required files
According to the system OS and CPU architecture, download Server JRE http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html here
Download and install 7-zip http://www.7-zip.org/download.html here
Download Zookeeper here and extract http://zookeeper.apache.org/releases.html with 7-zip
Download Kafka here and extract http://kafka.apache.org/downloads.html with 7-zip
For this tutorial, we unzipped Zookeeper and Kafka to disk C, but you can choose another location. Here we will use the full zookeeper instead of the one packaged with Kafka, because this is a single-node Zookeeper instance. You can also run Kafka packaged with zookeeper, located in the\ kafka\ bin\ windows library.
Installation
A. JDK installation
1. Start the JRE installation, select the check box "modify destination path", and then click install.
two。 Modify the installation directory with no spaces in the folder name, for example: C:\ Java\ jre1.8.0_xx\ (default is C:\ Program Files\ Java\ jre1.8.0_xx), and then click next.
3. Now click Control Panel-> system-> Advanced system Settings-> Environment variables to open the system environment variables dialog box.
4. Click the new user variable button in the user variable, then enter JAVA_HOME at the variable name, and fill in the variable value with the custom jre path. As shown in the following figure:
8. Confirm that the Java installation opens cmd, enter the type "java-version", and you should be able to see the version of java that you just installed.
Congratulations, Zookeeper is complete and running on port 2181.
c. Install Kafka
1. Enter the Kafka configuration directory, such as C:\ kafka_2.11-0.9.0.0\ config
two。 Edit the file "server.properties"
3. Find and edit "log.dirs=/tmp/kafka-logs" to "log.dir= C:\ kafka_2.11-0.9.0.0\ kafka-logs"
4. If Zookeeper is running on some other machine or cluster, you can change "zookeeper.connect:2181" to customize the IP and port. We used the same machine in this demonstration, so there is no need to modify it. The Kafka port and broker.id in the file are also configurable. Other settings remain the same.
5. Kafka runs on port 9092 by default and connects to the default port of zookeeper: 2181.
d. Run the Kafka server
Important: make sure that the Zookeeper instance is ready and running before starting the Kafka server.
1. Enter the Kafka installation directory C:\ kafka_2.11-0.9.0.0\
two。 Right-click Shift+, select the "Open Command window" option, and open the command line.
3. Now type.\ bin\ windows\ kafka-server-start.bat.\ config\ server.properties and enter.
.\ bin\ windows\ kafka-server-start.bat.\ config\ server.properties
5. Now that Kafka is ready and running, you can create topics to store messages. We can also generate or use data from Java/Scala code or directly from the command line.
e. Create a theme
1. Now create the theme and name it "test", replication factor=1 (because there is only one Kafka server running). If there is more than one Kafka server running in the cluster, replication-factor can be increased accordingly to improve data availability and system fault tolerance.
two。 Open a new command line at C:\ kafka_2.11-0.9.0.0\ bin\ windows.
3. Enter the following command and enter:
Kafka-topics.bat-create-zookeeper localhost:2181-replication-factor 1-partitions 1-topic test
6. Enter anything on the producer command line and enter; you can see the corresponding message in other consumer command lines.
7. If the message can be pushed to the client and displayed, the Kafka installation is complete.
Some useful commands: cd / home/work/soft/kafka_2.8.0-0.8.1.1/bin./kafka-topics.sh-- create-- zookeeper 10.48.170.26 topic test1 2181-- replication-factor 1-- partitions 3-- topic test./kafka-console- producer.sh-- broker-list 10.48.170.26 zookeeper 2181-- topic test1. List the topics:. / kafka-topics.sh-- list-- zookeeper 10.48.170.26 zookeeper 2181 2. Description topic:. / kafka-topics.sh-- describe-- zookeeper 10.48.170.26 zookeeper 2181-- topic [Topic Name] 3. Read the message from the beginning:. / kafka-console-consumer.sh-- zookeeper 10.48.170.26 topic 2181-- topic [Topic Name]-- from-beginning 4. Delete the topic:. / kafka-run-class.sh kafka.admin.TopicCommand-- delete-- topic [topic_to_delete]-- zookeeper 10.48.170.26 zookeeper 2181 Thank you for reading this article carefully. I hope the article "how to install and run Apache Kafka in Windows" shared by the editor will be helpful to you. At the same time, I also hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.