Zookeeper Series II: Common zookeeper commands

Source: Internet
Author: User

Zookeeper Series II: Common zookeeper commands

Http://blog.csdn.net/xiaolang85/article/details/13021339

Zookeeper service command:

After the corresponding configuration is ready, you can directly use the zkserver. Sh script to perform service-related operations.

  • 1. Start ZK service: Sh bin/zkserver. Sh start

  • 2. view the zk service status: Sh bin/zkserver. Sh status

  • 3. Stop ZK service: Sh bin/zkserver. Sh stop

  • 4. Restart the zk service: Sh bin/zkserver. Sh restart

    Example:

 

ZK client commands

The Zookeeper command line tool is similar to the Linux Shell environment, but it is certainly not as powerful as the shell, but we can use it for simple access to zookeeper, Data creation, data modification, and other operations. use zkcli. sh-server 127.0.0.1: 2181 connects to the zookeeper service. After the connection is successful, the system will output the environment and configuration information of zookeeper.

Some simple operations of the command line tool are as follows:

  • 1. Display files in the root directory: ls/use the LS command to view the content contained in the current zookeeper

  • 2. display the data in the root directory and file: ls2/view the data of the current node and the number of updates and other data

  • 3. Create a file and set the initial content: Create/ZK "test" to create a new znode node "zk" and its associated strings

  • 4. Get the file content: Get/ZK to check whether znode contains the string we created

  • 5. Modify the file content: Set/ZK "zkbak" to set the string associated with ZK

  • 6. delete the file: delete/ZK Delete the created znode

  • 7. Exit the client: Quit

  • 8. Help Command: Help

    Example:

 

Common four-character commands for zookeeper:

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.

  • 1. You can run the command echo stat | NC 127.0.0.1 2181 to check which node is selected as follower or leader.

  • 2. Run echo ruok | NC 127.0.0.1 2181 to test whether the server has been started. If you reply to imok, the server has been started.

  • 3. Echo dump | NC 127.0.0.1 2181, which lists unprocessed sessions and temporary nodes.

  • 4. Echo kill | NC 127.0.0.1 2181, disable Server

  • 5. Echo conf | NC 127.0.0.1 2181, which outputs detailed service configuration information.

  • 6. Echo cons | NC 127.0.0.1 2181, which lists the full connection/session details of all clients connected to the server.

  • 7. Echo ENVI | NC 127.0.0.1 2181, which outputs detailed information about the service environment (different from the conf command ).

  • 8. Echo reqs | NC 127.0.0.1 2181, which lists unprocessed requests.

  • 9. Echo wchs | NC 127.0.0.1 2181, which lists the Server watch details.

  • 10. Echo wchc | NC 127.0.0.1 2181, which lists the Server watch details through session. Its output is a list of watch-related sessions.

  • 11. Echo wchp | NC 127.0.0.1 2181, which lists the Server watch details in the path. It outputs a session-related path.

    Example:


Zookeeper Series II: Common zookeeper commands

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.