windows环境安装zookeeper图文讲解

来源:互联网 发布:格林数据 编辑:程序博客网 时间:2024/06/01 08:49

想要自己搭建一套zookeeper+dubbo+springmvc,所以一步一个脚印的来吧,先来本机搭建一下zookeeper。

1.下载zookeeper

http://zookeeper.apache.org/releases.html#download

2.把zookeeper的压缩包解压一下,指定到一个盘符下。


3.新建data文件夹以及logs文件夹,为了配合配置文件,下面会讲解。


4.修改配置文件

    找到conf文件夹下的zoo_sample.cfg文件,改名为zoo.cfg,并修改内容为:

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=E:\\environment\\zookeeper\\datadataLogDir=E:\\environment\\zookeeper\\logs # the port at which the clients will connectclientPort=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集群中包含多台server, 其中一台为leader, 集群中其余的server为follower,以下两个参数针对的是leader与follower之间的时长。

initLimit:参数配置初始化连接时的链接时间为initLimit*tickTime。

syncLimit:请求和应答的最大时间为syncLimit*tickTime。

dataDir: Zookeeper 保存数据的目录

dataLogDir: Zookeeper 保存日志文件的目录

clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。

5.启动

    进入到bin目录,并且启动zkServer.cmd,这个脚本中会启动一个java进程



5.验证是否启动成功

在cmd命令行中,执行jps,可以看到上文提到的java进程


6.启动一个客户端(可以直接启动bin目录下的zkCli.cmd)


 可以看到客户端显示已经连接成功。


服务器也已经有所响应。

ok,zookeeper搭建成功,下一篇文章,我们继续搭建dubbo。

0 0