Skip to content

Instantly share code, notes, and snippets.

@pydevops
Last active December 16, 2017 23:04
Show Gist options
  • Save pydevops/93e1d8a028110684d47fd062604e3522 to your computer and use it in GitHub Desktop.
Save pydevops/93e1d8a028110684d47fd062604e3522 to your computer and use it in GitHub Desktop.
zookeeper

check health

(leader only) echo dump | nc localhost 2181
echo stat | nc localhost 2181 
echo conf | nc localhost 2181
echo cons | nc localhost 2181
echo envi | nc localhost 2181

zk-shell

$./zookeeper-shell.sh 127.0.0.1:2181
Connecting to ....
Welcome to ZooKeeper!
JLine support is disabled

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
ls /brokers/ids
[1, 2, 3, 4, 5, 6]

API client

zkCli to verify the topic describe

zkCli> ls /brokers/topics/test_topic
zkCli> get /brokers/topics/test_topic
{"version":1,"partitions":{"0":[2,3,1]}}
cZxid = 0x100000f06
ctime = Wed Oct 11 23:46:51 UTC 2017
mZxid = 0x100000f06
mtime = Wed Oct 11 23:46:51 UTC 2017
pZxid = 0x100000f09
cversion = 1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 40
numChildren = 1

zkCli> get /config/topics/test_topic
{"version":1,"config":{"retention.ms":"1000"}}

Troubleshooting

Server not coming up because of file corruption A server might not be able to read its database and fail to come up because of some file corruption in the transaction logs of the ZooKeeper server. You will see some IOException on loading ZooKeeper database. In such a case, make sure all the other servers in your ensemble are up and working. Use "stat" command on the command port to see if they are in good health. After you have verified that all the other servers of the ensemble are up, you can go ahead and clean the database of the corrupt server. Delete all the files in datadir/version-2 and datalogdir/version-2/. Restart the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment