• Home
  • LLMs
  • Python
  • Docker
  • Kubernetes
  • Java
  • Maven
  • All
  • About
ZooKeeper | Verify ZooKeeper Status
  1. Verify if ZooKeeper is running
  2. Four letter words commands of ZooKeeper

  1. Verify if ZooKeeper is running
    To check the status of ZooKeeper:
    $ bin/zkServer.sh status
    ZooKeeper JMX enabled by default
    Using config: /opt/zookeeper-i1/bin/../conf/zoo.cfg
    Client port found: 2181. Client address: 0.0.0.0. Client SSL: false.
    Mode: follower

    To validate that ZooKeeper is listening on port 2181:
    $ netstat -lan | grep 2181
    tcp46      0      0  *.2181                 *.*                    LISTEN
    tcp4       0      0  10.0.0.21.54989        10.0.0.21.2181         TIME_WAIT
  2. Four letter words commands of ZooKeeper
    You can visit this page for the list of the four letter words commands https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_zkCommands

    To be able to execute the four letter words commands of ZooKeeper, you need to add the following property to "zoo.cfg" file:
    4lw.commands.whitelist=*

    You can also set Java system property: zookeeper.4lw.commands.whitelist

    You can run one of four letter words commands of ZooKeeper using nc command:
    $ echo "srvr" | nc localhost 2181
    Zookeeper version: 3.6.1-390fe37ea45dee01bf87dc1c042b5e3dcce88653, built on 05/03/2019 12:07 GMT
    Latency min/avg/max: 0/0/0
    Received: 3
    Sent: 2
    Connections: 1
    Outstanding: 0
    Zxid: 0x0
    Mode: standalone
    Node count: 5

    $ echo "stat" | nc localhost 2181
    Zookeeper version: 3.6.1-390fe37ea45dee01bf87dc1c042b5e3dcce88653, built on 05/03/2019 12:07 GMT
    Clients:
     /127.0.0.1:37924[0](queued=0,recved=1,sent=0)
    
    Latency min/avg/max: 0/0/0
    Received: 4
    Sent: 3
    Connections: 1
    Outstanding: 0
    Zxid: 0x0
    Mode: standalone
    Node count: 5

    $ echo "cons" | nc localhost 2181
    /127.0.0.1:37926[0](queued=0,recved=1,sent=0)

    You can also use telnet command to connect to the client port and execute the command srvr:
    $ telnet localhost 2181
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    srvr
    Zookeeper version: 3.6.1-390fe37ea45dee01bf87dc1c042b5e3dcce88653, built on 05/03/2019 12:07 GMT
    Latency min/avg/max: 0/0/0
    Received: 7
    Sent: 6
    Connections: 1
    Outstanding: 0
    Zxid: 0x0
    Mode: standalone
    Node count: 5
    Connection closed by foreign host.
© 2025  mtitek