Database Reference
In-Depth Information
You can also get a list of possible commands by entering any unrecognized command, such as help :
[zk: localhost:2181(CONNECTED) 1] help
ZooKeeper -server host:port cmd args
connect host:port
get path [watch]
ls path [watch]
set path data [version]
rmr path
delquota [-n|-b] path
quit
printwatches on|off
create [-s] [-e] path data acl
stat path [watch]
close
ls2 path [watch]
history
listquota path
setAcl path acl
getAcl path
sync path
redo cmdno
addauth scheme auth
delete path [version]
setquota -n|-b val path
To connect to one of the other ZooKeeper servers in the quorum, you would use the connect command,
specifying the server and its connection port. If, for example, you're currently on hc1r1m3, but want to connect to
hc1r1m1 (remember, all servers are connected via port 2181), you use the following:
[zk: localhost:2181(CONNECTED) 0] connect hc1r1m1:2181
[zk: hc1r1m1:2181(CONNECTING) 1] 2014-03-22 13:28:05,898 [myid:] - INFO [main-SendThread(hc1r1m1
:2181):ClientCnxn$SendThread@852] - Socket connection established to hc1r1m1/192.168.1.104:2181,
initiating session
2014-03-22 13:28:05,913 [myid:] - INFO [main-SendThread(hc1r1m1:2181):ClientCnxn$SendThread@1214] -
Session establishment complete on server hc1r1m1/192.168.1.104:2181, sessionid = 0x144e6df88b70004,
negotiated timeout = 30000
[zk: hc1r1m1:2181(CONNECTED) 1]
The result tells you that you are now connected to a ZooKeeper session on client node hc1r1m1 from hc1r1m3.
So far, you have ZooKeeper installed and have learned how to access it manually. In a large cluster, however, a
distributed application would connect to ZooKeeper automatically through one of its language APIs. It would use
the hierarchy of ZNodes to store configuration information. So, at this point you should examine the ZooKeeper
architecture in terms of those ZNodes to understand how they might be used for cluster configuration and
monitoring.
ZooKeeper stores its data in a hierarchy of nodes called ZNodes, each designed to contain a small amount of
data. When you log into the client, you can think of your session as similar to a Unix shell. Just as you can create
directories and files in a shell, so you can create ZNodes and data in the client.
 
Search WWH ::




Custom Search