Windows环境下安装和配置Zookeeper环境及常见错误解决方案

简介: ZooKeeper 是 Apache 软件基金会的一个软件项目,它为大型分布式计算提供开源的分布式配置服务、同步服务和命名注册。ZooKeeper 的架构通过冗余服务实现高可用性。本文主要讲解:1. 如何在Windows环境下搭建和配置Zookeeper2. Zookeeper配置文件配置与解析3. 常见错误及解决方案

1.下载Zookeeper安装文件

Zookeeper下载地址:https://downloads.apache.org/zookeeper/
根据自己的需求,找到对应的版本下载即可。image.png

本文以最新版3.7.0为例,进入3.7.0所在目录,点击下载bin.tar.gz文件

注意:从目前的最新版本3.5.5开始,带有bin名称的包才是我们想要的下载可以直接使用的里面有编译后的二进制的包,而之前的普通的tar.gz的包里面是只是源码的包无法直接使用

备用下载地址:https://wwe.lanzouo.com/b01ixumsd (密码:5tx8)
image.png

2.解压缩

将下载的tar.gz压缩文件解压至自己常用的目录中,本文章以解压中C://APP/Zookeeper下为例进行讲解。
解压完成后,在Zookeeper目录下新建data目录用于存放数据文件,目录结构如下:
image.png

3.修改配置文件

进入Zookeeper的conf目录,将zoo_sample.cfg复制一份并重命名为zoo.cfg
打开该配置文件修改其中的内容
主要修改的内容包括两项:data文件目录 和 Zookeeper端口号

注意:dataDir参数不要使用/tmp来做存储快照的目录,/tmp这只是一个案例。

image.png

Zookeeper配置文件详解
# The number of milliseconds of each tick
#CS通信心跳时间,单位是毫秒,系统默认是2000毫秒,即间隔两秒心跳一次。
#tickTime的意义:客户端与服务器或者服务器与服务器之间维持心跳,也就是每个tickTime时间就会发送一次心跳。
#通过心跳不仅能够用来监听机器的工作状态,还可以通过心跳来控制Flower跟Leader的通信时间,默认情况下FL的会话时常是心跳间隔的两倍。
tickTime=2000
# The number of ticks that the initial synchronization phase can take
#集群中的follower服务器(F)与leader服务器(L)之间初始连接时能容忍的最多心跳数(tickTime的数量)。
initLimit=10
# The number of ticks that can pass between sending a request and getting an acknowledgement
#集群中flower服务器(F)跟leader(L)服务器之间的请求和答应最多能容忍的心跳数。
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just example sakes.
#数据文件存放的目录,主要用来存放myid信息跟一些版本,日志,跟服务器唯一的ID信息等。
#不要使用/tmp来做存储快照的目录,/tmp这只是一个案例。
dataDir=../data
# the port at which the clients will connect
#客户端连接的接口,客户端连接zookeeper服务器的端口,zookeeper会监听这个端口,接收客户端的请求访问!默认是2181。
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
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

4. 启动Zookeeper

切换目录至bin目录下,在地址栏中输入cmd进入命令行界面zkServer.cmd并回车即可启动Zookeeper
image.png

当出现如下提示时,代表Zookeeper启动成功
image.png

5. Zookeeper启动验证

在命令行界面输入 zkCli.cmd可以进入Zookeeper客户端工具
在命令号中输入 create -e /test 123456 和 get /test可以创建和查看数据信息
image.png

常见错误及解决方案

1.错误:找不到或无法加载主类org.apache.zookeeper.server.quorum.QuorumPeerMain

下载对应的bin版本的安装包即可
https://developer.aliyun.com/article/831767

目录
相关文章
|
6月前
|
人工智能 JavaScript 开发工具
极速上手!Claude Code 原生支持 Windows 免WSL安装教程
Claude Code 现已支持 Windows 原生运行,无需 WSL 配置。本文提供详细安装教程,涵盖 Node.js 环境验证、Git 安装及 Claude Code 配置步骤,助你快速上手这一强大 AI 编程工具。
4619 5
|
6月前
|
存储 虚拟化 Windows
VMware安装Windows10
本案例介绍了在Windows系统上使用VMware Workstation 17.5 Pro安装配置Windows 10虚拟机的详细步骤,包括所需设备、软件下载链接、虚拟机设置及系统安装全过程。
2834 133
VMware安装Windows10
|
7月前
|
Ubuntu Unix Linux
在Windows上轻松安装和使用Ubuntu的方法详解
继续点击“Continue”按钮以继续安装流程,随后选择清理磁盘并安装操作系统的选项。 接下来,在安装过程中,你需要选择时区。为了与你的地理位置相匹配,请选择中国上海作为你的时区设置。 在安装过程中,你还需要设置计算机的名称以及账号密码。请务必牢记这些信息,因为它们将作为你登录系统的凭证。
|
5月前
|
安全 Ubuntu iOS开发
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
241 3
Nessus Professional 10.10 Auto Installer for Windows - Nessus 自动化安装程序
|
6月前
|
安全 数据安全/隐私保护 Windows
ZyperWin++使用教程!让Windows更丝滑!c盘飘红一键搞定!ZyperWin++解决系统优化、Office安装和系统激活
ZyperWin++是一款仅5MB的开源免费Windows优化工具,支持快速优化、自定义设置与垃圾清理,兼具系统加速、隐私保护、Office安装等功能,轻便无广告,小白也能轻松上手,是提升电脑性能的全能管家。
1852 0
|
7月前
|
Ubuntu Linux Windows
如何在Ubuntu系统中安装Wine,借此来运行Windows程序
熟悉的登录画面出现,在Ubuntu系统中扫描登录微信程序。
|
7月前
|
Ubuntu Linux Shell
手把手教你安装适用于Linux的Windows子系统——Ubuntu
重启完成,你看看重新打开Ubuntu是不是发生了变化,等待几分钟,系统配置完成,根据提示设置用户名和密码即可
|
7月前
|
Ubuntu Linux 数据安全/隐私保护
Windows上快速安装Linux子系统Ubuntu
Installing, this may take a few minutes...WslRegisterDistribution failed with error: 0x800701bcError: 0x800701bc WSL 2 ?????????????????? https://aka.ms/wsl2kernelPress any key to continue... 原因是 wsl1 升级到 wsl2 之后,内核却没有升级。 解决:下载最新的wsl安装包(wsl安装包)