首页 > 代码库 > ZooKeeper常用命令

ZooKeeper常用命令

  1. 在ZooKeeper ensemble中怎么查找Leader
    这里提供两种方法
    一种是在每个node上执行下面的命令看看哪个node是下面的输出
    # grep LEAD /var/log/zookeeper/zookeeper-zookeeper-server-xyz.out
    2016-02-29 22:33:47,113 - INFO  [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:QuorumPeer@829] - LEADING
    2016-02-29 22:33:47,114 - INFO  [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Leader@358] - LEADING - LEADER ELECTION TOOK - 9066

    另一种方法是在每个node上使用nc命令

    # echo stat | nc localhost 2181 | grep Mode
    Mode: leader
    
    # echo stat | nc localhost 2181 | grep Mode
    Mode: follower

     

ZooKeeper常用命令