Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to understand the running environment of ZooKeeper

Shulou Source: shulou.com Published: 2022-05-31 17:12:13 10月03日 Update

This article introduces you how to understand the ZooKeeper operating environment, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Document background:

ZooKeeper has been installed for some time. I stopped for a while, but I found it was rusty when I used it again today. Forget which machines in the cluster zookeeper are installed on.

Objective:

Now make the following notes on how to know zookeeper when you get a new zookeeper environment.

Content of the document:

1. Select a machine in your impression that zookeeper has been installed, and execute the following command [root@datanode1 ~] # echo $ZOOKEEPER_HOME/home/hadoop/modules/ zookeeper [root @ datanode1] # Note:

If there are more than 10 machines, but do not remember which machines their zookeeper is installed on, it will be a very sad thing. At present, I only know that one stupid way is to try one by one.

To avoid using the above stupid approach, we can document the machines in the hadoop cluster, record the roles of each machine, and what software is installed for later check.

2. Find the conf/zoo.cfg file [root@datanode1 ~] # echo $ZOOKEEPER_HOME/home/hadoop/modules/ zookeeper [root @ datanode1 ~] # less / home/hadoop/modules/zookeeper/conf/configuration.xsl log4j.properties zoo.cfg zoo_ sample.cfg [root @ datanode1 ~] # less / home/hadoop/modules/zookeeper/conf/zoo.cfg under the zookeeper installation directory

As can be seen from server.A=B:C:D, the running environment of zookeeper is composed of datanode1, datanode2 and datanode3 machines.

3. Confirm whether $ZOOKEEPER_HOME/conf/zoo.cfg is configured correctly in datanode2 and datanode3

4. Start zookeeper [root @ datanode2 ~] # zkServer.sh startJMX enabled by defaultUsing config: / home/hadoop/modules/zookeeper/bin/../conf/zoo.cfgStarting zookeeper on each machine of the zookeeper cluster. STARTED [root@datanode2 ~] #

Zookeeper does not have its own UI provider unless you install it yourself.

5. View the zookeeper output log

Here, pay attention to check the output log date. Here, the date is 06-02, which is obviously the previous history log, and today's log has not been printed (be sure to remember to check the date, otherwise it will be misled by the output log).

6. View the role to which the current node belongs

[root@datanode1 ~] # zkServer.sh statusJMX enabled by defaultUsing config: / home/hadoop/modules/zookeeper/bin/../conf/zoo.cfgMode: follower [root@datanode1 ~] # [root@datanode2 ~] # zkServer.sh statusJMX enabled by defaultUsing config: / home/hadoop/modules/zookeeper/bin/../conf/zoo.cfgMode: leader [root@datanode2 ~] # [root@datanode3 ~] # zkServer.sh statusJMX enabled by defaultUsing config: / home/hadoop/modules/zookeeper/bin/.. / conf/zoo.cfgMode: follower [root@datanode3 ~] #

It can be seen that datanode2 is leader,datanode1 and datanode3 bit follower.

7. Establish a connection to the service cluster zookeeper at any node

[root@datanode3] # zkCli.sh-server datanode2:2181 on how to understand the ZooKeeper operating environment to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Machine log environment cluster run content document date output method time more node role help good obvious rusty above things Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info vpn Docker Xiaomi