The previous article has been introduced. If you deploy multiple zookeeper instances on a single machine in a Windows environment, this article mainly explains the operations commands commonly used by zookeeper clients. Start Windows environment
Double-click the Zkserver.cmd script to start zookeeper, as shown below:
Linux Environment
Use the zkserver.sh script as follows: Start ZK service: SH bin/zkserver.sh start view ZK service status: SH bin/zkserver.sh status Stop ZK service: SH bin/zkserver.sh stop heavy Kai ZK Service: SH bin/zkserver.sh restart zookeeper client command connection Zookeeper
After starting the ZooKeeper service, we can use the following command to connect to the ZooKeeper service:
Zookeeper-3.4.8\bin>zkcli.cmd-server 127.0.0.1:2181
In the Linux environment:
After successful connection, the system will output the relevant environment and configuration information of ZooKeeper, as follows:
Common Commands
We can use the Help command to view assistance:
Some common operations commands for command-line tools are as follows: ls
Use the LS command to view all the files contained in a directory, such as:
[Zk:127.0.0.1:2181 (CONNECTED) 1] LS/
LS2
Use the LS2 command to view all the files contained in a directory, unlike LS, which looks at time, version, and other information
[Zk:127.0.0.1:2181 (CONNECTED) 1] LS2/
Create
Create the Znode and set the initial content, such as
Create a new Znode node "test" and the string associated with it get
Get the data for Znode as follows:
[Zk:127.0.0.1:2181 (CONNECTED) 1] get/test
Set
Modify Znode content, for example:
[Zk:127.0.0.1:2181 (CONNECTED) 1] set/test "Ricky"
Delete
Delete Znode
[Zk:127.0.0.1:2181 (CONNECTED) 1] delete/test
quit
Quit Client Help
Help commands
To this, Zookeeper common command part explained, the next one explains the use of Zookeeper Java API.
Resources:
https://zookeeper.apache.org