zookeeper windows下搭建与检测

步骤如下

 

1、下载zookeeper压缩包并解压,官网地址:http://www.apache.org/dyn/closer.cgi/zookeeper/
2、进入conf目录将 zoo_sample.cfg 改名为 zoo.cfg。
3、进入bin目录双击zkServer.cmd,若启动成功,则windows单机版zookeeper搭建成功!

 

需要修改的文件

 

修改zookeeper配置文件zoo.cfg
解压后进入conf目录,修改zoo_sample.cfg文件名为:zoo.cfg,这是因为zookeeper启动时默认加载zoo.cfg配置文件。修改zoo.cfg文件内容如下:

# The number of milliseconds of each tick
#tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
#默认情况下最小的会话超时时间为两倍的tickTime
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
#zookeeper集群中的包含多台server, 其中一台为leader, 集群中其余的server为follower. initLimit参数配置初始化连接时,
#follower和leader之间的最长心跳时间. 此时该参数设置为5, 说明时间限制为5倍tickTime, 即5*2000=10000ms=10s.
initLimit=5
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
#该参数配置leader和follower之间发送消息, 请求和应答的最大时间长度. 此时该参数设置为2, 说明时间限制为2倍tickTime, 即4000ms.
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
#dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
dataDir=D:\\zookeeper-3.4.8\\data
#dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
dataLogDir=D:\\zookeeper-3.4.8\\log
# the port at which the clients will connect
#clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns:限制连接到 ZooKeeper 的客户端的数量
#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

 

创建俩个文件夹

zookeeper windows下搭建与检测

 

 


改成:

指定dataDir,dataLogDir为这俩个文件夹位置

启动zookeeper
双击 zkServer.cmd,会出现命令窗口,窗口一直开启表示注册中心一直开着。

重启开启一个命令窗口,输入 jps,出现如下表示启动成功。

zookeeper windows下搭建与检测

 

 

 

注意:

1 如果出现启动闪退,在zkServer.cmd的倒数第二横添加pause,为了看错误

2 如果出现Java_home问题,在环境变量中添加Java_home

3 如果提示jps不是内部命令,在Java_home/bin下cmd运行 jps

 

上一篇:jvm的运行模式 client和 server两种


下一篇:Zookeeper