By default the whitelist only contains "srvr" command which zkServer.sh uses.
Try echo "srvr" | nc localhost 2181
or
set 4lw.commands.whitelist=*
see zookeeper doc 4lw.commands.whitelist
- 4lw.commands.whitelist : (Java system property: zookeeper.4lw.commands.whitelist) New in 3.5.3: A list of comma separated Four Letter Words commands that user wants to use. A valid Four Letter Words command must be put in this list else ZooKeeper server will not enable the command. By default the whitelist only contains "srvr" command which zkServer.sh uses. The rest of four letter word commands are disabled by default. Here's an example of the configuration that enables stat, ruok, conf, and isro command while disabling the rest of Four Letter Words command:
4lw.commands.whitelist=stat, ruok, conf, isro
If you really need enable all four letter word commands by default, you can use the asterisk option so you don't have to include every command one by one in the list. As an example, this will enable all four letter word commands:
4lw.commands.whitelist=*
Three of the more interesting commands: "stat" gives some general information about the server and connected clients, while "srvr" and "cons" give extended details on server and connections respectively.
Moving forward, Four Letter Words will be deprecated, please use AdminServer instead.
The new method of AdminServer is setting 4lw.commands.whitelist=*
and sending an HTTP request to http://localhost:8080/commands/stat
using wget
or curl
.
root@zoo2:/apache-zookeeper-3.8.0-bin# wget --quiet --output-document=/dev/stdout http://localhost:8080/commands/stat