ZooKeeper 客户端的使用
|
1
2
|
cd binzkCli.sh -timeout 5000 -server 27.154.242.214:5091 |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[zk: 27.154.242.214:5091(CONNECTED) 2] hZooKeeper -server host:port cmd args stat path [watch] set path data [version] ls path [watch] delquota [-n|-b] path ls2 path [watch] setAcl path acl setquota -n|-b val path history redo cmdno printwatches on|off delete path [version] sync path listquota path rmr path get path [watch] create [-s] [-e] path data acl addauth scheme auth quit getAcl path close connect host:port |
|
1
2
|
[zk: 27.154.242.214:5091(CONNECTED) 11] create /note1 123Created /note1 |
-s 表示是顺序节点 -e表示为临时节点
|
1
2
|
[zk: 27.154.242.214:5091(CONNECTED) 11] create/note2 123Created /note2 |
顺序节点
|
1
2
3
4
|
[zk: 27.154.242.214:5091(CONNECTED) 1] create -s /note1/note13 1333Created /note1/note130000000002[zk: 27.154.242.214:5091(CONNECTED) 2] create -s /note1/note13 1333Created /note1/note130000000003 |
查看节点状态
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[zk: 27.154.242.214:5091(CONNECTED) 12] stat /note1cZxid = 0xc0bctime = Sun Aug 21 07:42:06 CST 2016mZxid = 0xc0bmtime = Sun Aug 21 07:42:06 CST 2016pZxid = 0xc0bcversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0dataLength = 3numChildren = 0 |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[zk: 27.154.242.214:5091(CONNECTED) 13] get /note1123cZxid = 0xc0bctime = Sun Aug 21 07:42:06 CST 2016mZxid = 0xc0bmtime = Sun Aug 21 07:42:06 CST 2016pZxid = 0xc0bcversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0dataLength = 3numChildren = 0 |
ls2列出当前节点的子节点同时输出stat信息
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[zk: 27.154.242.214:5091(CONNECTED) 16] create /note1/note11 456[zk: 27.154.242.214:5091(CONNECTED) 18] create /note1/note12 789[zk: 27.154.242.214:5091(CONNECTED) 19] ls2 /note1 [note12, note11]cZxid = 0xc0bctime = Sun Aug 21 07:42:06 CST 2016mZxid = 0xc0bmtime = Sun Aug 21 07:42:06 CST 2016pZxid = 0xc0dcversion = 2dataVersion = 0aclVersion = 0ephemeralOwner = 0x0dataLength = 3numChildren = 2 |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
[zk: 27.154.242.214:5091(CONNECTED) 8] set /note1/note11 111cZxid = 0xc0cctime = Sun Aug 21 07:47:28 CST 2016mZxid = 0xc15mtime = Sun Aug 21 09:12:07 CST 2016pZxid = 0xc0ccversion = 0dataVersion = 1aclVersion = 0ephemeralOwner = 0x0dataLength = 3numChildren = 0[zk: 27.154.242.214:5091(CONNECTED) 9] get /note1/note11 111cZxid = 0xc0cctime = Sun Aug 21 07:47:28 CST 2016mZxid = 0xc15mtime = Sun Aug 21 09:12:07 CST 2016pZxid = 0xc0ccversion = 0dataVersion = 1aclVersion = 0ephemeralOwner = 0x0dataLength = 3numChildren = 0 |
删除节点
(rmr 循环删除节点及其子节点)
|
1
2
3
4
5
6
7
8
|
[zk: 27.154.242.214:5091(CONNECTED) 10] delete /note1/note11[zk: 27.154.242.214:5091(CONNECTED) 11] ls /note1 [note12, note130000000002, note130000000003][zk: 27.154.242.214:5091(CONNECTED) 12] delete /note1Node not empty: /note1[zk: 27.154.242.214:5091(CONNECTED) 13] rmr /note1[zk: 27.154.242.214:5091(CONNECTED) 14] ls / [server, zookeeper, config] |
配额相关的指令
设置配额
[setquota -n|-b val path]
-n限制子节点的个数 –b限制数据的长度
|
1
2
3
4
5
6
7
8
9
10
|
[zk: 27.154.242.214:5091(CONNECTED) 18] create /note1 123 Created /note1[zk: 27.154.242.214:5091(CONNECTED) 19] setquota -n 2 /note1 Comment: the parts are option -n val 2 path /note1[zk: 27.154.242.214:5091(CONNECTED) 20] create /note1/note11 11 Created /note1/note11[zk: 27.154.242.214:5091(CONNECTED) 21] create /note1/note12 12Created /note1/note12[zk: 27.154.242.214:5091(CONNECTED) 22] create /note1/note13 13 Created /note1/note13 |
发现超限了仅仅在日志记录超限信息的警告不会有异常如下:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[lzmhdev@lzmh01 zookeeper-3.4.8]$ cd bin [lzmhdev@lzmh01 bin]$ lsREADME.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh zookeeper.out[lzmhdev@lzmh01 bin]$ tail -f zookeeper.out at java.lang.Thread.run(Thread.java:745)2016-08-21 08:54:07,402 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:5091:NIOServerCnxn@1008] - Closed socket connection for client /123.59.54.18:34285 which had sessionid 0x156aa06f8d600012016-08-21 08:54:12,000 [myid:] - INFO [SessionTracker:ZooKeeperServer@355] - Expiring session 0x156aa06f8d60001, timeout of 5000ms exceeded2016-08-21 08:54:12,001 [myid:] - INFO [ProcessThread(sid:0 cport:5091)::PrepRequestProcessor@489] - Processed session termination for sessionid: 0x156aa06f8d600012016-08-21 08:54:21,201 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:5091:NIOServerCnxnFactory@192] - Accepted socket connection from /123.59.54.18:343382016-08-21 08:54:21,205 [myid:] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:5091:ZooKeeperServer@900] - Client attempting to establish new session at /123.59.54.18:343382016-08-21 08:54:21,223 [myid:] - INFO [SyncThread:0:ZooKeeperServer@645] - Established session 0x156aa06f8d60002 with negotiated timeout 5000 for client /123.59.54.18:343382016-08-21 09:14:54,075 [myid:] - INFO [ProcessThread(sid:0 cport:5091)::PrepRequestProcessor@651] - Got user-level KeeperException when processing sessionid:0x156aa06f8d60002 type:delete cxid:0x15 zxid:0xc17 txntype:-1 reqpath:n/a Error Path:/note1 Error:KeeperErrorCode = Directory not empty for /note12016-08-21 10:10:41,080 [myid:] - WARN [SyncThread:0:DataTree@389] - Quota exceeded: /note1 count=3 limit=2 |
查看指定数据节点的配额情况
|
1
2
3
4
|
[zk: 27.154.242.214:5091(CONNECTED) 23] listquota /note1absolute path is /zookeeper/quota/note1/zookeeper_limitsOutput quota for /note1 count=2,bytes=-1Output stat for /note1 count=4,bytes=9 |
-1 长度没有限制
删除配额
|
1
2
3
4
5
|
[zk: 27.154.242.214:5091(CONNECTED) 24] delquota -n /note1[zk: 27.154.242.214:5091(CONNECTED) 25] listquota /note1 absolute path is /zookeeper/quota/note1/zookeeper_limitsOutput quota for /note1 count=-1,bytes=-1Output stat for /note1 count=4,bytes=9 |
查看历史
并重复执行
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[zk: 27.154.242.214:5091(CONNECTED) 26] history16 - create /note117 - setquota -n 2 /note1 18 - create /note1 12319 - setquota -n 2 /note1 20 - create /note1/note11 1121 - create /note1/note12 1222 - create /note1/note13 1323 - listquota /note124 - delquota -n /note125 - listquota /note126 - history[zk: 27.154.242.214:5091(CONNECTED) 27] redo 25absolute path is /zookeeper/quota/note1/zookeeper_limitsOutput quota for /note1 count=-1,bytes=-1Output stat for /note1 count=4,bytes=9 |
ZooKeeper 客户端的使用的更多相关文章
- 【分布式】Zookeeper客户端
一.前言 前篇博客分析了Zookeeper的序列化和通信协议,接着继续学习客户端,客户端是开发人员使用Zookeeper最主要的途径,很有必要弄懂客户端是如何与服务端通信的. 二.客户端 2.1 客户 ...
- zookeeper 客户端编程
zookeeper是一个分布式的开源的分布式协调服务,用它可以来现同步服务,配置维护.zookeeper的稳定性也是可以保证的,笔者曾参与过的使用zookeeper的两个应用,一个是用zookeepe ...
- ZooKeeper客户端事件串行化处理
为了提升系统的性能,进一步提高系统的吞吐能力,最近公司很多系统都在进行异步化改造.在异步化改造的过程中,肯定会比以前碰到更多的多线程问题,上周就碰到ZooKeeper客户端异步化过程中的一个死锁问题, ...
- zookeeper客户端操作
ZooKeeper客户端 zkCli.sh 节点的增删改查 在 bin 目录下的 zkCli.sh 就是ZooKeeper客户端 ./zkCli.sh -timeout 5000 -server ...
- zookeeper客户端 zkCli使用及常用命令
上篇(http://www.cnblogs.com/yangzhenlong/p/8270835.html)zk伪集群搭建好后,使用zkCli连接zk服务 切换到zk1/bin 目录,执行zkCli. ...
- Zookeeper客户端Curator基本API
在使用zookeper的时候一般不使用原生的API,Curator,解决了很多Zookeeper客户端非常底层的细节开发工作,包括连接重连.反复注册Watcher和NodeExistsExceptio ...
- Zookeeper客户端Curator的使用,简单高效
Curator是Netflix公司开源的一个Zookeeper客户端,与Zookeeper提供的原生客户端相比,Curator的抽象层次更高,简化了Zookeeper客户端的开发量. 1.引入依赖: ...
- Zookeeper客户端介绍
客户端是开发人员使用Zookeeper的主要的途径,以下内容将对Zookeeper的内部原理进行详细的学习和讲解.ZooKeeper的客户端主要有一下几个核心组件组成: Zookeeper:提供客户端 ...
- ZooKeeper客户端 zkCli.sh 节点的增删改查
zkCli.sh 在 bin 目录下的 zkCli.sh 就是ZooKeeper客户端 ./zkCli.sh -timeout 5000 -server 127.0.0.1:2181 客户端与 ...
- Zookeeper客户端Curator使用详解
Zookeeper客户端Curator使用详解 前提 最近刚好用到了zookeeper,做了一个基于SpringBoot.Curator.Bootstrap写了一个可视化的Web应用: zookeep ...
随机推荐
- AnyConnect使用说明(手机版)
一.下载安装客户端 iPhone手机在App Store 里搜索 “Anyconnect”下载安装. Android手机需另外下载Anyconnect. 二. 1.打开AnyConnect,点击&qu ...
- UltraISO安装centos7系统
1. 使用最新版UltraISO将ISO镜像刻录到U盘一定要是最新版,试用版都可以,按下图操作: 2. U盘启动电脑进入安装界面正常情况下你应该会看到下面的这个界面: 选择第一项,然后按TAB键(在评 ...
- PHP 5 Directory 函数
PHP Directory 简介 Directory 函数允许您获得关于目录及其内容的信息. 安装 PHP Directory 函数是 PHP 核心的组成部分.无需安装即可使用这些函数. PHP 5 ...
- [总结] fhq_Treap 学习笔记
无旋版 $Treap$. 只需要两个操作即可达到 $splay$ 的所有功能 1.$split$ 它的主要思想就是把一个 $Treap$ 分成两个. $split$ 操作有两种类型,一种是按照权值分配 ...
- TCP的TIME_WAIT状态
主动关闭的Socket端会进入TIME_WAIT状态,并且持续2MSL时间长度,MSL就是maximum segment lifetime(最大分节生命期),这是一个IP数据包能在互联网上生存的最长时 ...
- Sqoop-1.4.6 Merge源码分析与改造使其支持多个merge-key
Sqoop中提供了一个用于合并数据集的工具sqoop-merge.官方文档中的描述可以参考我的另一篇博客Sqoop-1.4.5用户手册. Merge的基本原理是,需要指定新数据集和老数据集的路径,根据 ...
- Cassandra User 问题汇总(1)------------repair
Cassandra Repair 问题 问1: 文档建议每周或者每月跑一次full repair.那么如果我是使用partition rangerepair,是否还有必要在cluster的每个节点上定 ...
- 有一台机器,上面有m个储存空间。然后有n个请求,第i个请求计算时需要占 R[i]个空间,储存计算结果则需要占据O[i]个空间(据O[i]个空间(其中O[i]<R[i])。问怎么安排这n个请求的顺序,使
有一台机器,上面有m个储存空间.然后有n个请求,第i个请求计算时需要占 R[i]个空间,储存计算结果则需要占据O[i]个空间(据O[i]个空间(其中O[i]<R[i]).问怎么安排这n个请求的顺 ...
- Ubuntu下装QQ2014(http://my.oschina.net/oscfox/blog/315951)
QQ登陆界面: QQ登陆之后: 1.首先我们需要下载一个 deb的 Wine QQ安装包 qq2014官方下载:http://www.longene.org/download/WineQQ2013SP ...
- Web Service进阶(三)HTTP-GET, HTTP-POST and SOAP的比较
XML Web Service支持三种协议来与用户交流数据.这三种协议分别是: 1.SOAP:Simple Object Access Protocol 2.HTTP-GET 3.HTTP-POST ...