ZooKeeper介绍、使用及原理
2015-01-03 18:35
295 查看
Zookeeper简介
ZooKeeper 是 Apache 的一个顶级项目,为分布式应用提供高效、高可用的分布式协调服务,提供了诸如数据发布/订阅、负载均衡、命名服务、分布式协调/通知和分布式锁等分布式基础服务。由于 ZooKeeper 便捷的使用方式、卓越的性能和良好的稳定性,被广泛地应用于诸如 Hadoop、HBase、Kafka 和 Dubbo 等大型分布式系统中。
地址:http://zookeeper.apache.org
Zookeeper使用场景
1、命名服务在zookeeper的文件系统里创建一个目录,即获得唯一的path。
2、配置管理
多服务器或多个不同的应用,修改公共的配置文件比较困难,现在把这些配置放到zookeeper上去,保存在zookeeper的某个目录节点中,然后所有相关项目对这个节点进行监听,一旦配置信息发生变化,每个应用程序都会受到zookeeper的通知,然后从zookeeper获取新的配置文件到应用程序中。
3、集群管理
4、分布式锁
5、队列管理
Zookeeper安装和使用
版本:zookeeper-3.4.6.tar.gz 安装:解压zookeeper-3.4.6.tar.gz 即可
1、单机模式
解压zookeeper-3.4.6.tar.gz到某个目录如:C:\zookeeper-3.4.6\下,Zookeeper 的启动脚本在 bin 目录下,Windows 下的启动脚本是 zkServer.cmd。
执行前,需先修改配置文件:conf 目录下将 zoo_sample.cfg 改名为 zoo.cfg,因为 Zookeeper 在启动时会找这个文件作为默认配置文件。
配置文件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 # 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=1tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
配置好就可以启动 zkServer.cmd 了,可通过命令 netstat -ano 查看clientPort 端口号在监听服务。
2、集群模式
。。。。。。。。。。。。。。。。。。。。。。。。。。。
http://fengbin2005.iteye.com/blog/2007524
相关文章推荐
- 全面介绍ZooKeeper原理及使用
- cglib 介绍 原理 使用 demo examples 【转】
- cglib 介绍 原理 使用 demo examples
- zookeeper使用和原理探究(一)
- Git原理命令介绍 以及 eclipse下使用egit和git clone
- 有哪位兄台能给介绍一下推模式和拉模式的原理及使用。
- cglib 介绍 原理 使用 demo examples
- css sprite原理优缺点及使用示例介绍
- Zookeeper的原理介绍
- Lucene.net 原理介绍以及使用方法
- zookeeper使用和原理探究
- 使用SVN+CruiseControl+ANT实现持续集成之一----持续集成概念及CC原理介绍
- EasyMock使用方法和原理介绍
- RBAC原理介绍及开源框架kasai使用分析
- Timer与TimerTask的真正原理&使用介绍
- RBAC原理介绍及kasai使用分析
- 使用SVN+CruiseControl+ANT实现持续集成之一----持续集成概念及CC原理介绍
- offsetTop、offsetLeft、offsetWidth、offsetHeight原理使用介绍
- Android学习笔记---java实现多线程下载器,30_多线程下载原理介绍和使用
- zookeeper使用和原理探究(一)