windows系统安装zookeeper

      ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。zookeeper也是dubbo推荐使用的服务注册中心。那么windows系统下如何安装zooleeper,我把自己安装的详细过程记录下来,供大家参考:

1、下载zookeeper,官网下载一般比较慢,好在国内许多商业公司和高校都提供了开源镜像站,在此使用的清华大学的镜像服务站,zookeeper下载地址为:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/,我下载是3.4.13版本。

2、在任意文件夹下解压zookeeper,把zookeeper-3.4.13\conf 复制 zoo_sample.cfg 并粘贴到当前目录下,命名zoo.cfg。修改zoo.cfg 如下:

# 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=/tmp/zookeeper
#修改下面两行配置,如果没有直接添加,对应自己的zookeeper解压目录
dataDir=C:\MySoftInstall\zookeeper-3.4.13\data
dataLogDir=C:\MySoftInstall\zookeeper-3.4.13\log
# 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

#配置文件简单解析:
#1、tickTime:基本事件单元,以毫秒为单位。这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,它用来控制心跳和超时,也就是每个 tickTime #时间就会发送一个心跳。默认情况下最小的会话超时时间为两倍的 tickTime。
#2、clientPort:监听客户端连接的端口。这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
#3、dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
#4、dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录

3、在zookeeper-3.4.13文件夹下创建data,log文件夹,对应zoo.cfg中的配置。

4、在zookeeper-3.4.13/bin目录下,运行zkServer和zkCli

5、查看运行结果,至此zookeeper安装完成。

6、为了方便在cmd窗口使用zookeeper命令,可以把zookeeper-3.4.13/bin设置到环境变量中,这样我们就可以在cmd窗口直接执行zkServer和zkCli命令,而不用再到zookeeper-3.4.13/bin下去执行。

猜你喜欢

转载自blog.csdn.net/weixin_42315600/article/details/88652654
今日推荐