zookeeper features(summary)

本文探讨了ZooKeeper在高可用配置服务、锁服务、队列管理和统一命令服务等场景的应用。详细介绍了ZooKeeper的写入和读取流程,并解释了其如何通过临时顺序节点实现选举机制。此外还讨论了ZooKeeper的状态事件和节点事件监听机制,以及节点数据版本控制的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

**refer to zookeeper 3.2.2**

zookeeper 利用场合:

a.全局配置服务.

其实相当于是利用了zk的高可用性和快速访问的特点,可以将某些全局属性置于其中,当然 由于每个znode是1m存储上限,所以不能是大量的数据.事实上,可以把zk看成是高可用的文件系统也是可以的(high available file system)

 

b.锁服务

由于zk有EPHEMERAL_SEQUENTIAL创建znode的模式,所以当加入 一个新node时,自动在后缀加1;同时由于是ephemeral的,即便lock znode死了,其它znodes也可以重新进行leader election。

 

c.队列 管理

与b相似

 

d。统一命令服务

就是利用了它的树型目录结构的特点,产生唯一的名称。可以在建立znode时指定

 

---------------------

 

1.写流程



 从以上图可以看出,当client要写操作时,

a)通过已经连接上的follow(也可能是leader)生成一个Request,然后有一串的RequestProcessors传递,直到递到leader;

b1)leader此时开始2pc中的first phase:vote_request,

b2)各followers接受到vote_request后,进行决择 是否可以提交,返回 vote_commit或vote_abort;

--以上b为表决 阶段

c1)当leader收集到所有的表决 結果后进行分析 ,如果 commit人数大于指定quorum便生成一个global_commit,否则生成一个global_abort,transform to all flowers

c2)当所有followers收到leader命令后进行相应 操作,commit or abort 。

--以上c为决定阶段

  这样就 构成 一个distributed transaction commit 了。当然 实现上可能不至于这么简单。

  可以看出2pc无非就是比较1pc比了b phase,所以是比它安全多了,减少了不一致的概率。当然 ,2pc也可能出现 当global message传递时再现1pc中的情况,但按照概率 的理论,如果 cluster environment比较稳定时效果是理想的。

  当然为了防止leader失效时follower不知所措的情况,zookeeper实现为让followers自己重新elect,其实这也是3pc的实现呀!!

 

 置于具体的更新 过程,当follower收到global后,先是进行disk上的update,然后再对znode trees in memory 进行update.

 

 

2.读流程

  由于client已经连接上了follower,所以读取时直接从当前 peer上读取即可,这就是本页中 为什么可以快速访 问的原因 之一了。

当然它的过程与wite时是相反的,query from memory only .

 

 

3.zookeeper中的watch分为zookeeper status event 和 znode events,其中这些events都 是一次性的。即想要获得下次的event必须要调用读取方法时加入watch或true参数。

 

 

 

4.zk中的znode data也是有版本的:

[zk: localhost:2181(CONNECTED) 1] get /test
b
cZxid = 871
ctime = Wed May 25 14:45:32 CST 2011
mZxid = 880
mtime = Wed May 25 15:40:55 CST 2011
pZxid = 871
cversion = 0
dataVersion = 4

其中dataVersion就是真正的版本号,每次修改加1.在命令行中set path data [version]时,version就是此版本,如果 指定的版本与最新 版本不匹配时,将产生错误;置于api中setData(path,value,version)没试过,估计也是此意,此时-1代表忽略版本号。

 

 

5.簡易

zookeeper形如一个文件系统,高度精简。

 

6.decouple

类似spring ioc一样,zookeeper是独立运行的一个组件,可以置于项目中,也可以单独成群。

 

7.high avaiable

因为所有的server都是peer的运行在replicated mode中,避免了single point failure

 

8.快速访问capacity

由于读取直接从内存副本中直接 读取,避免了直接access disk的io开销

 

 

9.zk怎样实现广播式移除一个peer node?

参见 zab

 

10.zk怎样实现监听?

thread,http?

 

 

 

see also :http://leibnitz.iteye.com/blog/908805

http://zookeeper.apache.org/doc/r3.2.2/zookeeperOver.html

 

翻译OTE: As of HBase version 2.0, the hbck tool is significantly changed. In general, all Read-Only options are supported and can be be used safely. Most -fix/ -repair options are NOT supported. Please see usage below for details on which options are not supported. ----------------------------------------------------------------------- Usage: fsck [opts] {only tables} where [opts] are: -help Display help options (this) -details Display full report of all regions. -timelag <timeInSeconds> Process only regions that have not experienced any metadata updates in the last <timeInSeconds> seconds. -sleepBeforeRerun <timeInSeconds> Sleep this many seconds before checking if the fix worked if run with -fix -summary Print only summary of the tables and status. -metaonly Only check the state of the hbase:meta table. -sidelineDir <hdfs://> HDFS path to backup existing meta. -boundaries Verify that regions boundaries are the same between META and store files. -exclusive Abort if another hbck is exclusive or fixing. Datafile Repair options: (expert features, use with caution!) -checkCorruptHFiles Check all Hfiles by opening them to make sure they are valid -sidelineCorruptHFiles Quarantine corrupted HFiles. implies -checkCorruptHFiles Replication options -fixReplication Deletes replication queues for removed peers Metadata Repair options supported as of version 2.0: (expert features, use with caution!) -fixVersionFile Try to fix missing hbase.version file in hdfs. -fixReferenceFiles Try to offline lingering reference store files -fixHFileLinks Try to offline lingering HFileLinks -noHdfsChecking Don't load/check region info from HDFS. Assumes hbase:meta region info is good. Won't check/fix any HDFS issue, e.g. hole, orphan, or overlap -ignorePreCheckPermission ignore filesystem permission pre-check NOTE: Following options are NOT supported as of HBase version 2.0+. UNSUPPORTED Metadata Repair options: (expert features, use with caution!) -fix Try to fix region assignments. This is for backwards compatiblity -fixAssignments Try to fix region assignments. Replaces the old -fix -fixMeta Try to fix meta problems. This assumes HDFS region info is good. -fixHdfsHoles Try to fix region holes in hdfs. -fixHdfsOrphans Try to fix region dirs with no .regioninfo file in hdfs -fixTableOrphans Try to fix table dirs with no .tableinfo file in hdfs (online mode only) -fixHdfsOverlaps Try to fix region overlaps in hdfs. -maxMerge <n> When fixing region overlaps, allow at most <n> regions to merge. (n=5 by default) -sidelineBigOverlaps When fixing region overlaps, allow to sideline big overlaps -maxOverlapsToSideline <n> When fixing region overlaps, allow at most <n> regions to sideline per group. (n=2 by default) -fixSplitParents Try to force offline split parents to be online. -removeParents Try to offline and sideline lingering parents and keep daughter regions. -fixEmptyMetaCells Try to fix hbase:meta entries not referencing any region (empty REGIONINFO_QUALIFIER rows) UNSUPPORTED Metadata Repair shortcuts -repair Shortcut for -fixAssignments -fixMeta -fixHdfsHoles -fixHdfsOrphans -fixHdfsOverlaps -fixVersionFile -sidelineBigOverlaps -fixReferenceFiles-fixHFileLinks -repairHoles Shortcut for -fixAssignments -fixMeta -fixHdfsHoles Replication options -fixReplication Deletes replication queues for removed peers -cleanReplicationBrarier [tableName] clean the replication barriers of a specified table, tableName is required 25/05/30 11:00:17 INFO zookeeper.ClientCnxn: Opening socket connection to server cloudcdp03.hadoop.com/172.21.35.195:2181. Will not attempt to authenticate using SASL (unknown error) 25/05/30 11:00:17 INFO zookeeper.ClientCnxn: Socket connection established, initiating session, client: /172.21.35.166:34326, server: cloudcdp03.hadoop.com/172.21.35.195:2181 25/05/30 11:00:17 INFO zookeeper.ClientCnxn: Session establishment complete on server cloudcdp03.hadoop.com/172.21.35.195:2181, sessionid = 0xff9503965e37ba94, negotiated timeout = 60000 25/05/30 11:00:17 INFO zookeeper.ZooKeeper: Session: 0xff9503965e37ba94 closed 25/05/30 11:00:17 INFO zookeeper.ClientCnxn: EventThread shut down
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值