Operations commands commonly used by the zookeeper service

Source: Internet
Author: User
Tags zookeeper client scp command

After the zookeeper service is installed, it is common to install other big data platforms on the basis of this service, and other frameworks generally provide many interfaces to operate on the content of zookeeper, but the functions are relatively single, so sometimes It is necessary for us to login zookeeper server, the inside of the file structure has a certain understanding, so that the use is more convenient, the following simple summary of zookeeper commonly used commands.

The first is the most basic zkserver.sh script to use, as previously said, here is a summary (assuming the current directory in the Zookeeper installation directory):

1, Start zookeeper Service: bin/zkserver. SH start

2. View service status, including node type: bin/zkserver. SH status

3, Stop the service: bin/zkserver. SH Stop

4, restart the service: bin/zkserver. SH Restart

Here's the point, the use of ZK client tools, ZK's command-line tools and shell similar, but the command is relatively single, using much simpler than the shell, only simple data access operations, first use the following command to enter the command line management tool:

Bin/zkcli. sh -server localhost:2181

After using localhost or a defined host name, you can enter the tool interface after you enter, prompting such as to show:

  

At this point we can enter a command, enter a command, the last number plus 1, here are some common commands:

The LS/directory node displays the contents of the specified node in the zookeeper, for example: ls / or ls /configs but be aware that the start must be added/

LS2/Directory node view the contents of the specified node and the data of the node, the number of updates, such as: LS2/ or ls2/collections

Create/section name string creates a node and associates the specified string, for example: create/test thetest Note that there are no spaces in the middle of the string, and that the string does not have double quotes, this time with ls /test View will only return [], and with ls2/test , you can see information such as data length,

  

As you can see, datalength = 7

The Get/node or filename can get the string or the contents of the file associated with the node, similar to the Cat command under Linux, such as get / or get /configs/ Abc.xml

The former gets the directory's associated string, which gets the contents of the Abc.xml configuration file, which is equivalent to the cat command

Set/node name modifies the strings associated with the nodes, such as after creation, you can use: set /test Hello to modify the test node's associated string

Delete/file name deletes files on zookeeper, some framework profiles are often modified and cannot overwrite the original file each time it is updated, for example: delete/configs/abc/test.xml This is used to delete the Test.xml file, the next time you upload directly

Quit quit the Zookeeper client tool and return to the command line

Help to see more commands

In addition, you can do some things without logging in to zookeeper:

See if the node state is follower or leader: echo stat | NC 127.0. The full name of the 0.1 2181 NC is netcat, similar to the SCP command, which is used to transfer files between networks via TCP or UDP, with powerful functions such as hard disk cloning, port scanning, and so on, If you write an article detailing the details later, if the NC is not installed, you can install it using the Yum install NC.

Test if the service is started, if the display imok indicates that it has been started: echo Ruok | NC 127.0. 0.1 2181

List the details of the service configuration: echo conf | NC 127.0. 0.1 2181

List the details of the service environment (not the same as the previous conf): echo envi | NC 127.0. 0.1 2181

List unprocessed requests: echo reqs | NC 127.0. 0.1 2181

The above is commonly used zookeeper tools and other commonly used commands, the development and testing of related platforms will bring convenience

Operations commands commonly used by the zookeeper service

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.