Zookeeper common commands (RPM)

Source: Internet
Author: User

Original link:Zookeeper Series II: Zookeeper common CommandsZookeeper Service Command:

After you have prepared the appropriate configuration, you can perform the service operation directly through the zkserver.sh script.

    • 1. Start ZK service: SH bin/zkserver.sh start
    • 2. View ZK Service Status: SH bin/zkserver.sh status
    • 3. Stop ZK service: SH bin/zkserver.sh stop
    • 4. Restart ZK Service: SH bin/zkserver.sh restart

      The following example:

ZK Client Command

The Zookeeper command-line tool is similar to a Linux shell environment, but it is certainly less powerful than the shell, but with it we can simply access the zookeeper, create data, modify data, and so on. Using Zkcli.sh-server 127.0.0.1:2181 to connect to the ZooKeeper service, the system outputs the relevant environment and configuration information for ZooKeeper when the connection is successful.

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

    • 1. Display the root directory, file: LS/use the LS command to view the content contained in the current ZooKeeper
    • 2. Display the root directory, file: LS2/View the current node data and can see the number of updates and other data
    • 3. Create the file and set the initial content: Create/zk "Test" creates a new Znode node "ZK" and the string associated with it
    • 4. Get the contents of the file: Get/zk confirm if Znode contains the string we created
    • 5. Modify the contents of the file: Set/zk "Zkbak" sets the string associated with ZK
    • 6. Delete file: Delete/zk The znode you just created is deleted
    • 7. Exit the client: Quit
    • 8. Help command:

      The following example:

ZooKeeper commonly used four word command:

ZooKeeper supports the interaction of some specific four-word command letters. Most of them are query commands that are used to obtain the current state of the ZooKeeper service and related information. The user can submit the appropriate command to the ZooKeeper via Telnet or NC at the client

    • 1. You can use the command: Echo stat|nc 127.0.0.1 2181来 to see which node is selected as follower or leader
    • 2. Use echo ruok|nc 127.0.0.1 2181 to test if the server is started, if the reply Imok indicates that it has been started.
    • 3. Echo dump| NC 127.0.0.1 2181, which lists the unprocessed sessions and temporary nodes.
    • 4. Echo Kill | NC 127.0.0.1 2181, turn off server
    • 5. Echo conf | NC 127.0.0.1 2181, output the details of the related service configuration.
    • 6. Echo Cons | NC 127.0.0.1 2181, which lists full connection/session details for all clients connected to the server.
    • 7. Echo envi |nc 127.0.0.1 2181, output detailed information about the service environment (as distinct from the Conf command).
    • 8. Echo reqs | NC 127.0.0.1 2181, which lists the unprocessed requests.
    • 9. Echo Wchs | NC 127.0.0.1 2181, listing the details of the server watch.
    • echo WCHC | NC 127.0.0.1 2181, the session lists the details of the server watch, and its output is a list of watch-related sessions.
    • echo WCHP | NC 127.0.0.1 2181, which lists the details of the server watch by path. It outputs a path associated with the session.

      The following example:

Zookeeper common commands (RPM)

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.