Verifying Zookeeper

What is Zookeeper:

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. - https://zookeeper.apache.org/

There are several ways to test the zookeeper service

Option 1: Jps

Zookeeper is a Java process and when you start a Zookeeper instance it runs a org.apache.zookeeper.server.quorum.QuorumPeerMain class. So you can check for a running Zookeeper like this:

$ jps -l | grep zookeeper

Option 2: using zookeeper command

Zookeeper provides a number of 4 letter word commands. You can run them like below.

$ echo ruok | nc einext02 2181

2181 is the standard port for zookeeper service.

View the full list of available zookeeper commands in the following link

https://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands

envi: Print details about serving environment

reqs: List outstanding requests

ruok: Tests if server is running in a non-error state. The server will respond with imok if it is running. Otherwise it will not respond at all.

stat: Lists statistics about performance and connected clients.

Option 3: checking linux service

Zookeeper runs as linux daemon. You can check the status of the service.

$ sudo service zookeeper-server status

Configuration file for zookeeper

/etc/zookeeper/conf/zoo.cfg

zkCli - Zookeeper CLI

Launch zookeeper cli as below. You can view services that are configured using zkCli

$ /usr/lib/zookeeper/bin/zkCli.sh -server einext02:2181

[zk: einext02:2181(CONNECTED) 0] ls /

[hbase, hive_zookeeper_namespace, zookeeper]

[zk: einext02:2181(CONNECTED) 1] ls /hbase

[meta-region-server, backup-masters, table, draining, region-in-transition, table-lock, running, master, namespace, hbaseid, online-snapshot, replication, splitWAL, recovering-regions, rs, flush-table-proc]

Get metadata for /hbase application

[zk: einext02:2181(CONNECTED) 6] get /hbase

cZxid = 0x4

ctime = Mon Aug 15 19:19:59 IST 2016

mZxid = 0x4

mtime = Mon Aug 15 19:19:59 IST 2016

pZxid = 0x4f5

cversion = 52

dataVersion = 0

aclVersion = 0

ephemeralOwner = 0x0

dataLength = 0

numChildren = 16

Theoretical Background:

In theoretical computer science, the CAP theorem, also named Brewer's theorem after computer scientist Eric Brewer, states that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees:

  • Consistency (all nodes see the same data at the same time)

  • Availability (every request receives a response about whether it succeeded or failed)

  • Partition tolerance (the system continues to operate despite arbitrary partitioning due to network failures)

(wikipedia)

Zookeeper relaxes availability over consistency and partition tolerance.