windows11搭建kafka环境
一:安装java的jdk和配置环境变量
1.1、下载安装jdk
1.2 配置java环境变量
参考:https://zhuanlan.zhihu.com/p/364700617
二 zookeeper安装配置
2.1 下载解压配置
下载
地址:https://downloads.apache.org/zookeeper/
配置文件
创建“zoo.cfg”:D:\Java\zookeeper-3.4.14\conf\zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=D:/Java/zookeeper-3.4.14/data
dataLogDir=D:/Java/zookeeper-3.4.14/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
1.2 配置系统变量
配置:ZOOKEEPER_HOME
值:D:\Java\zookeeper-3.4.14
配置:path
添加:%ZOOKEEPER_HOME%\bin
2.3 启动验证
启动服务端:
D:\Java\zookeeper-3.4.14\bin
zkServer.cmd
启动客户端验证:
D:\Java\zookeeper-3.4.14\bin
zkCli.cmd
如果出现:[zk: localhost:2181(CONNECTED) 0]说明成功
执行:ls / 命令进入zookeerper根目录
[zk: localhost:2181(CONNECTED) 0] ls /
三:安装配置kafka
3.1、下载kafka
下载地址:https://downloads.apache.org/kafka/
3.2、配置kafka
在目录:
D:\Java\kafka_2.11-0.11.0.1\config
找到:server.properties
设置:log.dirs=D:\Java\kafka_2.11-0.11.0.1\logs
设置:zookeeper.connect=127.0.0.1:2181
3.3、启动验证
.\bin\windows\kafka-server-start.bat .\config\server.properties
cmd中切换到:D:\Java\kafka_2.11-0.11.0.1>.\bin\windows\kafka-server-start.bat .\config\server.properties
kafka启动成功!
也可以在zookeerper的客户端中再次执行:ls /
多出来的文件夹就是kafka生成的!