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.