windows安装zookeeper-单机模式

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows安装zookeeper-单机模式相关的知识,希望对你有一定的参考价值。

  • zookeeper下载地址:http://zookeeper.apache.org/releases.html#download   本次使用的是3.4.9版本
  • 前提:请安装JDK
  • 安装:
  1. 创建安装目录,将下载的zookeeper-3.4.9.tar.gz压缩包解压
  2. windows启动脚本在bin目录下zkServer.cmd
  3. 启动之前,修改配置文件;Zookeeper 的配置文件在 conf 目录下,这个目录下有 zoo_sample.cfg 和 log4j.properties,需要将 zoo_sample.cfg 改名为 zoo.cfg,因为 Zookeeper 在启动时会找这个文件作为默认配置文件;配置文件项如下:  
# 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:/work/emm_windows/zookeeper-3.4.9/data
# 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

    各项含义:

tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper 服务器的客户端,而是 Zookeeper 服务器集群中连接到 Leader 的 Follower 服务器)初始化连接时最长能忍受多少个心跳时间间隔数。当已经超过 10 个心跳的时间(也就是 tickTime)长度后 Zookeeper 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。总的时间长度就是 5*2000=10 秒
syncLimit:这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2*2000=4 秒
dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。

  4.配置完成后,双机bin目录下的zkServer.cmd启动

技术分享

 

      5.检查服务是否启动,可以通过 netstat – ano 命令查看是否有你配置的 clientPort 端口号在监听服务

 

以上是关于windows安装zookeeper-单机模式的主要内容,如果未能解决你的问题,请参考以下文章

Windows安装和使用zookeeper

Windows下zookeeper注册中心的安装和启动

Zookeeper安装,Zookeeper单机模式安装

Zookeeper安装使用--单机模式

linux安装zookeeper(单机模式)

Zookeeper实战之单机模式