Windows上的Zookeeper

8xiog9wr  于 2022-12-09  发布在  Apache
关注(0)|答案(3)|浏览(127)

我在Windows环境中运行Zookeeper时遇到一些困难。
我下载了zookeeper 3.4.6。解压了它。在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=/tmp/zookeeper
# 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

然后我试着从bin文件夹运行zkServer.cmd。但是我不确定它是否能运行。
如何测试Zookeeper服务器是否在Windows上运行?

ej83mcc0

ej83mcc01#

如果你想看到结果,以管理员身份从Windows命令行工具运行zkServer.cmd,而不是单击它,它将在最后关闭,你将无法看到结果。
此外,您应该将dataDir更新为有效的Windows目录,格式为C:/tmp/...
在命令行上,调用zkServer.cmd之后,您应该能够在命令行上看到不同的[INFO]消息,最后一个消息绑定到端口0.0.0.0/0.0.0.0:2181。

flvtvl50

flvtvl502#

下面是用于Windows的命令:
C:\kafka_2.12-2.3.1>.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
C:\kafka_2.12-2.3.1>.\bin\windows\kafka-server-start.bat .\config\server-1.properties
C:\kafka_2.12-2.3.1>.\bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9093 --partitions 2 --replication-factor 2 --topic user-tracking
C:\kafka_2.12-2.3.1>.\bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9093

8cdiaqws

8cdiaqws3#

确保你的zookeeper服务器没有在windows中运行。甚至在docker中也没有激活(如果安装了的话)。如果在docker中激活,禁用docker。
运行以下命令

%KAFKA_HOME%\bin\windows\zookeeper-server-stop.bat

您将收到如下响应-

No Instance(s) Available.

然后运行以下命令:

%KAFKA_HOME%\bin\windows\zookeeper-server-start.bat KAFKA_HOME%\etc\kafka\zookeeper.properties

相关问题