8.0 Zookeeper Four-Letter Commands
Category Zookeeper Tutorial
Zookeeper supports certain specific four-letter commands for interaction, allowing users to obtain the current status and related information of the Zookeeper service. Users can submit corresponding commands to Zookeeper via telenet or nc (netcat) from the client.
Install nc command:
$ yum install nc # CentOS
or
$ sudo apt install netcat # Ubuntu
Four-letter command format:
echo [command] | nc [ip] [port]
Commonly used four-letter commands in ZooKeeper are as follows:
Four-Letter Command | Functional Description |
---|---|
conf | Introduced in version 3.3.0. Prints detailed information about service-related configurations. |
cons | Introduced in version 3.3.0. Lists all the connection/session details of clients connected to this server. Includes information such as "received/sent" packet counts, session ID, operation latency, last operation performed, etc. |
crst | Introduced in version 3.3.0. Resets connection and session statistics for all connections. |
dump | Lists important sessions and ephemeral nodes. This command is only useful on the leader node. |
envi | Prints detailed information about the service environment. |
reqs | Lists unprocessed requests. |
ruok | Tests whether the service is in the correct state. If so, the service returns "imok"; otherwise, it does not respond. |
stat | Outputs a list of clients about performance and connections. |
srst | Resets server statistics. |
srvr | Introduced in version 3.3.0. Lists detailed information about the server connections. |
wchs | Introduced in version 3.3.0. Lists detailed information about server watches. |
wchc | Introduced in version 3.3.0. Lists detailed information about server watches by session. Its output is a list of sessions related to watches. |
wchp | Introduced in version 3.3.0. Lists detailed information about server watches by path. It outputs a path related to a session. |
mntr | Introduced in version 3.4.0. Outputs a list of variables that can be used to detect the health status of the cluster. |
>
Refer to the official link: https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_4lw
Four-Letter Command Usage
stat Command
The stat command is used to view the status information of zk, example as follows:
$ echo stat | nc 192.168.3.38 2181
ruok Command
The ruok command is used to check if the current zkserver is started; if it returns imok, it indicates normal operation. Example as follows:
$ echo ruok | nc 192.168.3.38 2181
dump Command
The dump command is used to list unprocessed sessions and ephemeral nodes. Example as follows:
$ echo dump | nc 192.168.3.38 2181
conf Command
The conf command is used to view server configuration. Example as follows:
$ echo conf | nc 192.168.3.38 2181
cons Command
The cons command is used to display information about clients connected to the server. Example as follows:
$ echo cons | nc 192.168.3.38 2181
envi Command
The envi command is used to view environment variables. Example as follows:
$ echo envi | nc 192.168.3.38 2181
5.0 Zookeeper Data Model znode Structure Detailed Explanation
8.0 Zookeeper Four-Letter Commands