四字命令
conf
New in 3.3.0
Print details about serving configuration.
输出服务配置的详细信息。
cons
New in 3.3.0
List full connection/session details for all clients connected to this server. Includes information on numbers of packets received/sent, session id, operation latencies, last operation performed, etc…
列出所有连接到服务器的客户端的连接/会话的详细信息。包括接收/发送包数量、会话id、操作延迟、最后进行的操作等…
crst
New in 3.3.0
Reset connection/session statistics for all connections.
重置所有连接的连接/会话统计信息。
dump
Lists the outstanding sessions and ephemeral nodes. This only works on the leader.
列出未经处理的会话和临时节点。此命令仅对leader有效。
envi
Print details about serving environment.
输出服务环境的详细信息。
ruok
Tests if server is running in a non-error state. The server will respond with imok if it is running. Otherwise it will not respond at all.
测试服务是否处于正确状态。如果确实如此,那么服务返回“ imok ”,否则不做任何相应
A response of “imok” does not necessarily indicate that the server has joined the quorum, just that the server process is active and bound to the specified client port. Use “stat” for details on state wrt quorum and client connection information.
srst
Reset server statistics.
重置服务器统计信息。
srvr
New in 3.3.0
Lists full details for the server.
列出所有的服务器详细信息。
stat
Lists brief details for the server and connected clients.
输出服务器信息和连接客户端的概要列表。
wchs
New in 3.3.0
Lists brief information on watches for the server.
列出服务器观察者的概要信息。
wchc
New in 3.3.0
Lists detailed information on watches for the server, by session. This outputs a list of sessions(connections) with associated watches (paths). Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.
通过session列出服务器观察者的详细信息,它的输出是一个与观察者(路径)相关的会话(连接)的列表。注意,取决于观察者的数量,此操作可能会非常消耗资源(影响服务器性能),请小心使用,
wchp
New in 3.3.0
Lists detailed information on watches for the server, by path. This outputs a list of paths (znodes) with associated sessions. Note, depending on the number of watches this operation may be expensive (ie impact server performance), use it carefully.
通过路径列出服务器观察者的详细信息。它输出一个与 session相关的路径(节点)。注意,取决于观察者的数量,此操作可能会非常消耗资源(影响服务器性能),请小心使用,
mntr
New in 3.4.0
Outputs a list of variables that could be used for monitoring the health of the cluster.
输出一份可以监控集群健康状态的变量列表。
四字命令使用方法
zkClient使用命令
客户端连接
ls
列出某路径下所有节点
ls path [watch]
create
创建节点
create [-s] [-e] path data acl
get
获取节点信息
get path [watch]
set
为节点重新赋值
set path data [version]
delete
删除节点
delete path [version]
history
查看执行命令历史记录
history
redo
重做某一步
redo cmdno
stat
打印节点状态
stat path [watch]
close
关闭当前连接
close
connect
当close当前连接或者以外退出后,可以继续在zkCli的命令模式下连接。
connect host:port
quit
退出当前会话
quit
setAcl path acl
为某个节点设置ACL权限。
setAcl path acl
getAcl path
查看某个节点的ACL权限。
getAcl path
addauth scheme auth
添加认证信息,类似于登录。如果某个节点需要认证后才能查看,则需要此命令。
addauth scheme auth
不常用
- rmr path
- ls2 path [watch]
- listquota path
- sync path
-
delquota [-n|-b] path
-
printwatches on|off
-
setquota -n|-b val path
参考资料
百度百科:zookeeper
Zookeeper官网:http://zookeeper.apache.org/
《从PAXOS到ZOOKEEPER分布式一致性原理与实践》 - 倪超
ZooKeeper Commands: The Four Letter Words http://zookeeper.apache.org/doc/r3.4.9/zookeeperAdmin.html#sc_zkCommands