zookeeper单机安装

在“dubbo入门”一文中,我们提到把注册中心这个概念,也就是服务提供者需要把服务接口都注册到这里。

在“dubbo入门”中,如果要使用zookeeper作为注册中心,首先,你要安装zookeeper,并启动该服务。本文就先来说说zookeeper的安装吧~~~

  1. 下载
    官网地址
    image.png
  1. 安装
    下载下来是个压缩包,解压,


    image.png

然后进入目录:zookeeper-3.4.14/conf/
拷贝zoo_sample.cfg,并重命名为zoo.cfg,


image.png

编辑zoo.cfg,


# 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 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。
# 总的时间长度就是 5*2000=10 秒
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
# 这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2*2000=4 秒
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
# 顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里
dataDir=C:\software\zookeeper-3.4.14\data
dataLogDir=C:\software\zookeeper-3.4.14\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.
#
# 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. 启动服务
    先启动zkServer.cmd,


    image.png

别关闭该服务,然后再启动zkCli.cmd,


image.png

看到下面的提示信息,证明启动成功,


image.png
  1. 上述操作成功后,“dubbo入门”一文中使用zookeeper作为注册中心那就没问题了。

  2. zookeeper提供:文件系统+监听通知机制。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。