概述
ZooKeeper是Hadoop的开源子项目(Google Chubby的开源实现),它是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置管理、命名服务、分布式锁、集群管理等。
本文主要讲述如何在Windows环境上搭建ZooKeeper集群环境,注意是在一台Windows机器上部署3个ZooKeeper实例。
本文介绍的 Zookeeper 是以 3.4.8 稳定版本为基础,下载链接:http://zookeeper.apache.org/releases.html
配置
我在本地Windows机器上部署3个ZooKeeper实例,目录结构如下:
其中,Server_A,Server_B,Server_C各自都拥有一个ZooKeeper实例;ZK_data用来存储ZooKeeper数据信息;ZK_log用来存储ZooKeeper日志信息。
解压缩
将下载下来的zookeeper-3.4.8.tar.gz解压缩到F:\ZooKeeper\ZK_Cluster\Server_A目录下,如下图所示:
修改zoo.cfg
将conf/zoo_sample.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.