玩转zookeeper,首先了解一下zookeeper是什么东西,ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,它是集群的管理者,监视着集群中各个节点的状态根据节点提交的反馈进行下一步合理操作。最终,将简单易用的接口和性能高效、功能稳定的系统提供给用户。
zookeeper它能为HDFS,HBase,Mapreduce,Yarn,HIve等组件提供重要的功能支撑。
zookeeper的特性:
(1)强一致性:
client无论连接到那个Server,展示给他的都是同一个视图,这是zookeeper的一个主要特性。
(2)可靠性:
如果消息被一台服务器接收那么将会被所有服务器接收
(3)实时性:zookeeper保证客户端在读取时间之前调用Sync实现
(4)等待无关:慢或者已经失效的client不得干预其他的client工作。
(5)原子性:更新只能成功或者失败,没有中间状态。
(6)顺序性:包括全局有序以及偏序两种。
配置文件中信息如下:
# The number of milliseconds of each tick
tickTime=2000
tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
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
2、dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。(这个是zookeeper下载下来之后没有的,但是可以自己建立,类似于Tomcat.log之类的东西。)
dataLogDir=D:\zookeeper\log
dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录(保持日志文件的目录)
the port at which the clients will connect
clientPort=2181
(clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。)这是经常会用到的用于去监听客户的请求。端口号是可以改变的。
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
#