ZooKeeper客户端命令

通过客户端脚本zkCli.sh连接到服务器

  • ls / //列出zk中包含的内容

  • create /node1 helloworld //创建node1节点并指定关联字符串

  • get /node1 //查询节点数据

  • set /node1 howareyou //向节点写入数据

  • delete /node1 //删除节点

  • stat /node1 //显示自身状态数据,不显示携带的数据

  • close 关闭连接

  • connect s2:2181 //连接zk

通过客户端脚本zkCli.sh连接到服务器

  • zkCli.sh -server s:2181

    //连接成功后如下信息

    Welcome to Zookeeper....

  • help //输出帮助信息

ZooKeeper Stat Structure

  • czxid The zxid of the change that caused this znode to be created.

  • mzxi The zxid of the change that last modified this znode.

  • ctime The time in milliseconds from epoch when this znode was created.

  • mtime The time in milliseconds from epoch when this znode was last modified.

  • version The number of changes to the data of this znode.

  • cversion The number of changes to the children of this znode.

  • aversion The number of changes to the ACL of this znode.

  • ephemeralOwner The session id of the owner of this znode if the znode is an ephemeral node. If it is not an ephemeral node, it will be zero.

  • dataLength The length of the data field of this znode.

  • numChildren The number of children of this znode.