在CDH中管理Zookeeper并查看zk状态

2020-05-19  本文已影响0人  青丝如梦

参考:
https://www.dcdapp.com/article/6797960622504935944

image.png

如何在CDH中管理Zookeeper并查看zk状态?

  1. Zookeeper安装目录

CDH版本的zk位于如下目录下:

/opt/cloudera/parcels/CDH-5.9.2-1.cdh5.9.2.p0.3/lib/zookeeper/
  1. 常用命令
启动ZK服务:bin/zkServer.sh start

查看ZK服务状态:bin/zkServer.sh status

停止ZK服务:bin/zkServer.sh stop

重启ZK服务:bin/zkServer.sh restart

连接服务器:zkCli.sh -server 127.0.0.1:2181

客户端连接

运行 zkCli.sh –server <ip>进入命令行工具

在CDH中管理Zookeeper并查看zk状态

客户端命令

在CDH中管理Zookeeper并查看zk状态

查看znode路径

查看根目录:

[zk: localhost:2181(CONNECTED) 0] ls  /
[zookeeper, consumers,hbase,kylin]

查看其它节点中的内容:

[zk:  localhost:2181(CONNECTED) 1] ls  /hbase
[table, running]
[zk:  localhost:2181(CONNECTED) 2] ls  /zookeeper
[quota]

创建节点

创建testnode节点,关联字符串”mytest”

[zk:  localhost:2181(CONNECTED) 3]  create /zookeeper/testnode "mytest"
 Created /zookeeper/testnode

获取znode数据

[zk: localhost:2181(CONNECTED) 4]  get /zookeeper/testnode
mytest
cZxid = 0x4b00000f2
ctime = Wed Jan 08 13:26:09 CST 2019
mZxid = 0x4b00000f2
mtime = Wed Jan 08 13:26:09 CST 2019
pZxid = 0x4b00000fd
cversion = 3
dataVersion = 6
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 2

设置节点内容

[zk: localhost:2181(CONNECTED) 5]  set /zookeeper/testnode mytest2
cZxid = 0x4b00000f2
ctime = Wed Jan 08 13:27:09 CST 2019
mZxid = 0x4b00000f2
mtime = Wed Jan 08 13:27:09 CST 2019
pZxid = 0x4b00000fd
cversion = 3
dataVersion = 7
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 7
numChildren = 2

删除节点

9.[zk: localhost:2181(CONNECTED) 6] delete /zookeeper/testnode

退出客户端

[zk: localhost:2181(CONNECTED) 6] quit
Quitting...
... ...
上一篇下一篇

猜你喜欢

热点阅读