老鬼的博客 来都来啦,那就随便看看吧~
windows下载安装启动zookeeper
发布于: 2023-02-28 更新于: 2023-02-28 分类于:  阅读次数: 

一:介绍

1
2
3
4
5
6
7
8
9
10
11
12
ZooKeeper 是一个典型的分布式数据一致性解决方案,
分布式应用程序可以基于 ZooKeeper 实现诸如数据
发布/订阅、负载均衡、命名服务、分布式协调/通知、
集群管理、Master 选举、分布式锁和分布式队列等功能。

ZooKeeper一个最常用的使用场景就是用于担任服务生
产者和服务消费者的注册中心。

服务生产者将自己提供的服务注册到 ZooKeeper 中心,
服务的消费者在进行服务调用的时候先到 ZooKeeper 中
查找服务,获取到服务生产者的详细信息之后,再去调用
服务生产者的内容与数据。

二:下载

1.jpg

三:配置和启动

3.1目录介绍

1
2
3
bin:指令相关
conf:配置相关
docs:文档

2.jpg

3.2 配置数据和日志目录

1
2
3
4
在zookeeper根目录下创建data和log目录,分别存储数据和日志,
将conf下的zoo_sample.cfg复制成zoo.cfg,加入如下配置:
dataDir=data
dataLogDir=log
  • 完整配置如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# The number of milliseconds of each tick
# 这个时间是作为 Zookeeper 服务器之间或客户端
# 与服务器之间维持心跳的时间间隔,也就是每个
# tickTime 时间就会发送一个心跳。
tickTime=2000

# The number of ticks that the initial
# synchronization phase can take
# 这个配置项是用来配置 Zookeeper 接受客户端
#(这里所说的客户端不是用户连接 Zookeeper 服务
# 器的客户端,而是 Zookeeper 服务器集群中连接
# 到 Leader 的 Follower 服务器)初始化连接时最
# 长能忍受多少个心跳时间间隔数。当已经超过 10
# 个心跳的时间(也就是 tickTime)长度后 Zookeeper
# 服务器还没有收到客户端的返回信息,那么表明这个
# 客户端连接失败。总的时间长度就是 10*2000=20 秒
initLimit=10

# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# 这个配置项标识 Leader 与 Follower 之间发送消息,
# 请求和应答时间长度,最长不能超过多少个 tickTime
# 的时间长度,总的时间长度就是 5*2000=10 秒
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# dataDir=/tmp/zookeeper

# 设置数据存储和日志存储路径
dataDir=data
dataLogDir=log


# the port at which the clients will connect
# 这个端口就是客户端连接 Zookeeper 服务器的端口,
# Zookeeper 会监听这个端口,接受客户端的访问请求。
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.
#
# https://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.httpHost=0.0.0.0
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

3.3 启动

1
2
3
4
5
点击bin/zkServer.cmd,我这里封装了自己的dos指令
start_zk.bat
D:
cd D:\my-tools\zookeeper\apache-zookeeper-3.8.1-bin\bin
start zkServer.cmd

3.jpg

4.jpg

四:可视化客户端

4.1 ZooViewer(可视化客户端1)

4.1.1 下载地址
4.1.2 如何使用
  • github
1
2
从github下载下来的文件解压后有一个ZooViewer.zip,
解压后双击startup.bat即可运行然后输入端口号连接
  • 自己的包
1
直接点击bulid下的startup.bat运行即可,然后输入端口号连接

5.jpg

6.jpg

4.2 ZooInspector(可视化客户端2)

4.2.1 下载
4.2.2 如何使用
1
2
3
4
5
6
直接双击运行build下的zookeeper-dev-ZooInspector.jar,
我这里自己写了个startup.bat的脚本如下:
java -jar zookeeper-dev-ZooInspector.jar
pause

启动后点击左上角绿色的开始按钮,点击连接

7.jpg
7.jpg
7.jpg

*************感谢您的阅读*************