Skip to content

Instantly share code, notes, and snippets.

@miguno
Created May 29, 2015 13:56
Show Gist options
  • Save miguno/d6e3c4cdc5cd846c7728 to your computer and use it in GitHub Desktop.
Save miguno/d6e3c4cdc5cd846c7728 to your computer and use it in GitHub Desktop.
Rudimentary check whether all servers/members of a ZooKeeper ensemble are synchronized / in sync.
$ for zk in `seq 1 3`; do echo stat | nc zookeeper${zk} 2181|egrep "^(Zxid|Node)"; done
Zxid: 0x46d1b3ebc
Node count: 4557
Zxid: 0x46d1b3ebc
Node count: 4557
Zxid: 0x46d1b3ebf
Node count: 4557
# All values should be the same, though with ongoing transactions from clients you might see the values
# to diverge slightly (e.g. if you wait 1 second in between querying `stat` from zookeeper1 and zookeeper2,
# zookeeper2's `Zxid` values might be "higher" simply because additional transactions were received and
# processed during the 1sec wait).
#
# Of course there are other reasons why the values can be different -- legitimate failures like network
# partitions are another cause, for example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment