Zookeeper Series 3: zookeeper commands, command line tools, and simple operations

Source: Internet
Author: User

Problem Guidance
1. What Common commands does zookeeper contain?
2. What command can be used to list the watch details of the server?
3. What operations does zookeeper contain?
4. How does zookeeper create zookeeper?



Common commands


Zookeeper supports the interaction between certain four-character command letters. Most of them are query commands used to obtain the current status and related information of the zookeeper service. You can use Telnet or NC to submit commands to zookeeper on the client. Common four-character commands for zookeeper are shown in table 1 below:

 

Table 1: zookeeper command

 

Zookeeper command Function Description
Conf Output detailed service configuration information.
Cons Lists the full connection/session details of all clients connected to the server. Including the number of "Accept/Send" packets, session ID, Operation delay, and last operation execution.
Dump Lists unprocessed sessions and temporary nodes.
ENVI Output detailed information about the service environment (different from the conf command ).
Reqs List unprocessed requests
Ruok Test whether the service is in the correct status. If so, the service returns "imok"; otherwise, no response is made.
Stat Output A list of performance and connected clients.
Wchs List the detailed information of the server watch.
Wchc A session is used to list the detailed information of the server watch. Its output is a list of watch-related sessions.
Wchp List the detailed information of the server watch in the path. It outputs a session-related path.

 

1 is a simple example of the zookeeper command:

 

<Ignore_js_op> Figure 1: zookeeper Command case

 




Command line tool:

 

After the zookeeper service is successfully started, enter the following command to connect to the zookeeper service:
  1. Zkcli. Sh-server 10.77.20.23: 2181
Copy code

 

After the connection is successful, the system outputs the relevant environment and configuration information of zookeeper, and outputs "Welcome to zookeeper" and other information on the screen. After you enter help, the available zookeeper commands are displayed, as shown in 1:

 

<Ignore_js_op> Figure 1: zookeeper command

 




Zookeeper simple operation 1) Use the LS command to view the content contained in the current zookeeper:
  1. [ZK: 10.77.000023: 2181 (connected) 1] ls/
  2. [Zookeeper]
Copy code

 

2) create a new znode and use create/ZK mydata. This command creates a new znode node "zk" and the strings associated with it:




  1. <Div style = "text-align: Left;"> <span style = "line-Height: 1.5;"> [ZK: 10.77.20.23: 2181 (connected) 2] Create/ZK mydata </span> </div> <Div style = "text-align: Left;"> <span style = "line-Height: 1.5; "> created/ZK </span> </div>
Copy code




3) run the LS command again to view the content contained in zookeeper:
  1. [ZK: 10.77.000023: 2181 (connected) 3] ls/
  2. [ZK, Zookeeper]
Copy the code and you will see that the zk node has been created.



4) run the GET command to check whether the znode created in step 2 contains the string we created:
  1. [ZK: 10.77.000023: 2181 (connected) 4] GET/ZK
  2. Mydata
  3. Zxid = 0x40000000c
  4. Time = Tue Jan 18 18:48:39 CST 2011
  5. Zxid = 0x40000000c
  6. Mtime = Tue Jan 18 18:48:39 CST 2011
  7. Pzxid = 0x40000000c
  8. Cversion = 0
  9. Dataversion = 0
  10. Aclversion = 0
  11. Ephemeralowner = 0x0
  12. Datalength = 6
  13. Numchildren = 0
Copy code



5) Below we use the set command to set the string associated with ZK:
  1. [ZK: 10.77.000023: 2181 (connected) 5] Set/ZK shenlan211314
  2. Czxid = 0x40000000c
  3. Ctime = Tue Jan 18 18:48:39 CST 2011
  4. Mzxid = 0x40000000d
  5. Mtime = Tue Jan 18 18:52:11 CST 2011
  6. Pzxid = 0x40000000c
  7. Cversion = 0
  8. Dataversion = 1
  9. Aclversion = 0
  10. Ephemeralowner = 0x0
  11. Datalength = 13
  12. Numchildren = 0
Copy code



6) Below we will delete the created znode:
  1. [ZK: 10.77.000023: 2181 (connected) 6] delete/ZK
Copy code

 

7) run the LS command again to view the content of zookeeper:
  1. [ZK: 10.77.000023: 2181 (connected) 7] ls/
  2. [Zookeeper]
Copy code

 

After verification, the zk node has been deleted. Article transferred from: http://www.aboutyun.com/thread-9310-1-1.html

Zookeeper Series 3: zookeeper commands, command line tools, and simple operations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.