Zookeeper under linux starts

Zookeeper installation directory: /usr/local/zookeeper-3.4.6/bin/zkServer.sh;

Configuration file path: ../conf/zoo.cfg

port: 2181;

 

ZooKeeper service command:

     After preparing the corresponding configuration, you can directly use the zkServer.sh script to perform service-related operations

  • 1. Start the ZK service: sh bin/zkServer.sh start
  • 2. Check the ZK service status: sh bin/zkServer.sh status
  • 3. Stop the ZK service: sh bin/zkServer.sh stop
  • 4. Restart the ZK service: sh bin/zkServer.sh restart

zk client command

The ZooKeeper command line tool is similar to the Linux shell environment, but the function is definitely not as good as the shell, but using it we can simply access ZooKeeper, create data, modify data and other operations. Use zkCli.sh -server 127.0.0.1:2181 to connect To the ZooKeeper service, after the connection is successful, the system will output the relevant environment and configuration information of ZooKeeper.

Some simple operations of command line tools are as follows:

  • 1. Display the root directory and files: ls / Use the ls command to view the content contained in the current ZooKeeper
  • 2. Display the root directory and files: ls2 / View the current node data and see the update times and other data
  • 3. Create the file and set the initial content: create /zk "test" creates a new znode "zk" and the string associated with it
  • 4. Get the file content: get /zk to confirm whether the znode contains the string we created
  • 5. Modify the content of the file: set /zk "zkbak" Set the string associated with zk
  • 6. Delete the file: delete /zk delete the znode just created
  • 7. Exit the client: quit
  • 8. Help command: help
 

ZooKeeper commonly used four-word commands:

      ZooKeeper supports interactions with certain four-word command letters. Most of them are query commands to get the current status and related information of the ZooKeeper service. Users can submit corresponding commands to ZooKeeper through telnet or nc on the client side

  • 1. You can use the command: echo stat|nc 127.0.0.1 2181 to check which node is selected as follower or leader
  • 2. Use echo ruok|nc 127.0.0.1 2181 to test whether the server is started. If it replies imok, it means it has been started.
  • 3. echo dump | nc 127.0.0.1 2181 , list unprocessed sessions and temporary nodes.
  • 4. echo kill | nc 127.0.0.1 2181 , turn off the server
  • 5. echo conf | nc 127.0.0.1 2181 , output the detailed information of related service configuration.
  • 6. echo cons | nc 127.0.0.1 2181 , lists the full connection/session details of all clients connected to the server.
  • 7. echo envi |nc 127.0.0.1 2181 , output detailed information about the service environment (different from the conf command).
  • 8. echo reqs | nc 127.0.0.1 2181 , list unhandled requests.
  • 9. echo wchs | nc 127.0.0.1 2181 , list the details of the server watch.
  • 10. echo wchc | nc 127.0.0.1 2181 , lists the details of the server watch through session, and its output is a list of sessions related to watch.
  • 11. echo wchp | nc 127.0.0.1 2181 , list the details of the server watch by path. It outputs a path associated with the session.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325249361&siteId=291194637