Custom Search

Sunday, March 15, 2015

How to use Apache ZooKeeper zkCli Command Line Interface

a)
Find zookeeper Cli

#locate zkCli

b)
Find process ID of zookeeper

#sudo ps -aux | grep zoo

 

c)
Find port of zookeeper using process ID

#sudo netstat -tuplen | grep 3876
tcp6       0      0 :::2181                 :::*                    LISTEN      1000       14046       3876/java      
tcp6       0      0 :::33040                :::*                    LISTEN      1000       13626       3876/java

* Two instance (port 2181 and 33040) of zookeeper service are running

d)
Connect to zookeeper server

#cd /opt/stack/contrail/third_party/zookeeper-3.4.6/bin/
#./zkCli.sh -server 192.168.56.102:2181


* http://zookeeper.apache.org/doc/r3.3.3/zookeeperStarted.html

e)
Get zookeeper Cli commands

[zk: 192.168.56.102:2181(CONNECTED) 0] help

f)
List path

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /[svc-monitor, id, schema-transformer, fq-name-to-uuid, api-server, zookeeper]

* schema-transformer creates "/id"

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /fq-name-to-uuid

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /id

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /schema-transformer

[zk: 192.168.56.102:2181(CONNECTED) 13] ls /svc-monitor

g)
Get data from path


* Get ID of default IPAM "default-network-ipam" in the "default-project" project.
[zk: 192.168.56.102:2181(CONNECTED) 36] get /fq-name-to-uuid/network_ipam:default-domain:default-project:default-network-ipam
0bee2fa4-766d-438f-9991-0fe4b34577b8

* Get ID of IPAM "ipam333" in the "admin" project.
[zk: 192.168.56.102:2181(CONNECTED) 37] get /fq-name-to-uuid/network_ipam:default-domain:admin:ipam333
1d54fc41-8697-4747-ab1f-f85ad53ac59d

h)
Set data


* Set ID of IPAM "ipam333" in the "admin" project.
[zk: 192.168.56.102:2181(CONNECTED) 44] set /fq-name-to-uuid/network_ipam:default-domain:admin:ipam333 1d54fc41-8697-4747-ab1f-f85ad53ac599

i)
Delete Path

i1)
[zk: localhost:2181(CONNECTED) 12] get /fq-name-to-uuid/global_system_config:default-global-system-config
a9f53855-477f-4509-bd40-9297470b7a0b
cZxid = 0xa
ctime = Thu Oct 15 05:42:46 UTC 2015
mZxid = 0xa
mtime = Thu Oct 15 05:42:46 UTC 2015
pZxid = 0xa
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 36
numChildren = 0

i2)
[zk: localhost:2181(CONNECTED) 12] rmr /fq-name-to-uuid/global_system_config:default-global-system-config

i3)
[zk: localhost:2181(CONNECTED) 13] get /fq-name-to-uuid/global_system_config:default-global-system-config
Node does not exist: /fq-name-to-uuid/global_system_config:default-global-system-config

No comments:

Post a Comment