zookeeper安装与使用 windows
简介:
zookeeper是一个分布式的,开放源码的分布式协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。他是为分布式提供一致性的服务软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。
zookeeper主要将一些重要的服务封装起来,将简单易用的接口和性能高效、功能稳定的系统提供给用户。
ZooKeeper包含一个简单的原语集,提供Java和C的接口。
ZooKeeper代码版本中,提供了分布式独享锁、选举、队列的接口,代码在zookeeper-3.4.8\src\recipes。其中分布锁和队列有Java和C两个版本,选举只有Java版本。
一个例子:
假设我是一家KTV的老板,我同时拥有5家KTV,我肯定得时刻监视我KTV 的情况吧,是不是有人打架,或者发生火灾什么的,这时候我会给设置一个视频监控,然后每一家都连接到我的视频监控里面,那么我就可以在家里看到所有KTV 的情况了,如果某一家出现问题,我就能及时发现,并且做出反应。
这个视频监控就相当于zookeeper,每一家的连接,就相当于KTV 的信息
下载:
# 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:\\zookeeper\\data dataLogDir=D:\\zookeeper\\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
配置文件简单解析:
tickTime:该参数就是服务端到一定时间久会固定给客户端发送一个消息,保证zookeeper正常状态,心跳检查。
dataDir:保存数据文件的目录,默认情况下,zookeeper的日志记录也会在这个文件夹下。
dataLogDir:指定日志保存目录,目录结构用\\隔开。
clientPort:连接服务器的端口,zookeeper会监听这个端口,接收客户端的请求,然后服务端进行处理。
启动:
进入到bin目录,并且启动zkServer.cmd,这个脚本中会启动一个java进程,启动后jps可以看到QuorumPeerMain的进程,也可以启动客户端连接一下。

浙公网安备 33010602011771号