Costin Costin - 2 years ago 97
Bash Question

read znode without using any zookeeper client

There is in my cluster a Zookeeper server (I know its IP) which stores my data. I cat get that data using a custom Java application.

Is there any possibility to get the data from

in a shell, without using the zkCli? I do not have any zookeeper client installed and for various reasons it is complicated to install one.

I'm looking for something like
echo 'stat' | nc 2181
, but
echo 'get /a/b' | nc .....
do not retrieve anything.

Thanks :)

Answer Source

ZooKeeper is a complicated protocol for reasons innately linked to its core purpose: A protocol-compliant client is required to communicate with multiple servers to ensure that the answer it receives is up-to-date.

Moreover, the protocol in question involves packed binary structures, making it inamenable to implementation in native shell.

I would suggest:

  • If your restrictions against installing new software are in some way specific to the upstream Zookeeper client (for instance, specific to Java), consider an alternate client such as zookeepercli or (should you be amenable to writing some Python code) Kazoo.
  • If you don't need the level of robustness Zookeeper's protocol otherwise guarantees, consider running a service on your ZooKeeper servers which uses a native client library to perform lookups, returning results over HTTP or raw sockets, thus allowing curl or nc to be used from your scripts elsewhere.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download