bin/zookeeper-shell.sh作用是连接zookeeper,并通过命令查询注册的信息,本质上就是zookeeper的语法。
bin/zookeeper-shell.sh zookeeper_host:port[/path] [args…]
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.连接zookeeper
bin/zookeeper-shell.sh 127.0.0.1:2181
2.ls path
查看节点列表, ls path 和 ls2 path 两个命令,后者是前者的增强,不仅可以查看指定路径下的所有节点,还可以查看当前节点的信息。
ls /
[cluster, controller, controller_epoch, brokers, zookeeper, admin, isr_change_notification, consumers, log_dir_event_notification, latest_producer_id_block, config]
ls /brokers/ids
[0]
ls /brokers/topics
[topic1]
3 get path
获取某子节点的值
get /brokers/ids/0
{"listener_security_protocol_map":{"PLAINTEXT":"PLAINTEXT"},"endpoints":["PLAINTEXT://10.43.39.215:9092"],"jmx_port":-1,"host":"10.43.39.215","timestamp":"1574497721055","port":9092,"version":4}
cZxid = 0x1d
ctime = Sat Nov 23 16:28:41 CST 2019
mZxid = 0x1d
mtime = Sat Nov 23 16:28:41 CST 2019
pZxid = 0x1d
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x16e976072140000
dataLength = 194
numChildren = 0
状态属性 说明
cZxid 数据节点创建时的事务 ID
ctime 数据节点创建时的时间
mZxid 数据节点最后一次更新时的事务 ID
mtime 数据节点最后一次更新时的时间
pZxid 数据节点的子节点最后一次被修改时的事务 ID
cversion 子节点的更改次数
dataVersion 节点数据的更改次数
aclVersion 节点的 ACL 的更改次数
ephemeralOwner 如果节点是临时节点,则表示创建该节点的会话的 SessionID;如果节点是持久节点,则该属性值为 0
dataLength 数据内容的长度
numChildren 数据节点当前的子节点个数