In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how Python calls kafka to build and apply. The content is concise and easy to understand, and it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Recently, we have encountered a requirement that we need to develop the current resource-consuming interfaces into asynchronous communication mechanisms. To put it simply, there is a message queue for continuous centralized message distribution and task processing. The solution given by the application side here is to use kafka to do this, but I haven't touched this before, so I don't have a clue, so I just think.
Let's start with the installation of the kafka environment. The installation of kafka depends on the zooeleeper module. Although kafka comes with the zooeleeper module, all the tutorials on the Internet say that you still need to install the zooeleeper module manually in advance, so the first step here is to install the zooeleeper module. Download it here:
Http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/
What I downloaded is version 3.4.14:
The installation is very simple, extract it directly to the local, and then follow the steps below:
1. After decompressing, enter the directory conf, and rename "zoo_sample.cfg" to "zoo.cfg" (the default port of zookeeper is 2181. If you need to change it, you can edit zoo.cfg) 2. Enter the bin directory, click zkServer.cmd to run 3, and the command line displays as follows, indicating that the operation is successful.
After installing and starting the zooeleeper module successfully, you can download and install the kafka module. Here you need to pay attention to downloading the appropriate version. Many tutorials on the Internet are relatively early, so the version information given may not be found or may no longer be appropriate. Here I groped to try to install. After the first installation failed, I checked a lot of tutorials and found that the scala I installed was not correct. The important thing to note here is that kafka is written based on scala, so if you want to successfully install kafka, you must ensure that scala is successfully installed.
Another important point or note to download kafka is the need to download and install binary files. My download link here is as follows:
Http://kafka.apache.org/downloads
What I downloaded is the following version:
After downloading it locally, you can decompress it directly. The screenshot of the result is as follows:
After entering the current directory, open the CMD window and execute the following command:
.\ bin\ windows\ kafka-server-start.bat.\ config\ server.properties
No accident, as long as the previous environmental conditions are met, here should be able to start normally, the terminal will output a lot of dense logs.
At this point, kafka is successfully installed, and you can use it on your own.
To put it briefly here, there are some problems encountered when writing the program, and the errors are as follows:
Exception in thread kafka-python-producer-1-network-thread (most likely raised during interpreter sh
To solve the above error report, you need to deal with two areas, which are as follows:
1. Modify the system hosts file
Go to C:\ Windows\ System32\ drivers\ etc to open the hosts file as a manager
Add a new line of 127.0.0.1 localhost at the end
Save exit
2. Modify the configuration file corresponding to kafka
Go to the config folder
Open server.properties
Add the following two lines under line 31 # listeners=PLAINTEXT://:9092 of the file
Advertised.listeners = PLAINTEXT://localhost:9092 advertised.listeners = PLAINTEXT://127.0.0.1:9092
Save exit
The effect image is as follows:
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.