Install and use Kafka under Windows (using Kafka's built-in ZooKeeper graphic-text version)

Install Kafka on Windows

1. Install JDK and configure the corresponding environment variables

insert image description here

● Create a new folder jre
insert image description here

● 1. The environment variables are as follows - the installation path
insert image description here

● 2. Click path to create new
insert image description here

● 3. Create a system variable
insert image description here

.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

2. Install and configure Zookeeper

1. Download the installation package Apache Zookeeper

download

2. Unzip and enter the Zookeeper directory

● 2.1 Rename zoo_sample.cfg under conf to zoo.cfg
insert image description here

● 2.2 Open zoo.cfg, modify data storage location dataDir
dataDir=D:/OnlineSoftWare/apache-zookeeper-3.7.1/data

dataDir=D:/OnlineSoftWare/apache-zookeeper-3.7.1/data
# 防止端口8080启动后被占用,这里考虑先配置下
admin.serverPort=8081

To prevent port 8080 from being occupied after startup, consider configuring it first

admin.serverPort=8081
insert image description here

● 2.3 Add system variables
insert image description here

● 2.4 Create a new one in path
insert image description here

3. Open a new cmd, enter "zkServer", and run Zookeeper
insert image description here

● As long as no error is reported, it is successful. If an error is reported, the following only needs to configure the admin port of 2.2

Caused by: java.io.IOException: Failed to bind to /0.0.0.0:8080
    at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:346)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:396)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.apache.zookeeper.server.admin.JettyAdminServer.start(JettyAdminServer.java:103)
    ... 5 more
Caused by: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342)
        ... 12 more
Unable to start AdminServer, exiting abnormally

Note that this interface cannot be closed~ because kafka needs to start zookeeper first!

3. Install Kafka

3.1 Download the installation package

Kafka download
Download the binary version, as shown in the figure
insert image description here

3.2. Unzip and enter the Kafka directory,

Author: D:\OnlineSoftWare\kafka_2.13-3.3.1
insert image description here

3. Enter the config directory to find the file server.properties and open it,
find and edit the location where the logs are saved log.dirs, listener, where kafka-logs is the folder you created

listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://localhost:9092
log.dirs=D:\OnlineSoftWare\kafka_2.13-3.3.1\kafka-logs
broker.id=1

insert image description here

Enter the Kafka installation directory D:\OnlineSoftWare\kafka_2.13-3.3.1, press Shift+right click, select the "Open Command Window" option, and open the command line

insert image description here

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

insert image description here

The installation is complete here!

The installation under linux is still being written...

Guess you like

Origin blog.csdn.net/weixin_59823583/article/details/131042496