Zookeeper (4) - Zookeeper distributed installation

Deploy Zookeeper on the three nodes bigdata111, bigdata112 and bigdata113.

  1. Unzip the zookeeper installation package.

    tar -zxvf zookeeper-3.4.10.tar.gz -C /usr/local/
    
  2. Create zkData.

    cd /usr/local/zookeeper-3.4.10
    mkdir -p zkData
    
  3. Rename zoo_sample.cfg to zoo.cfg, and modify the configuration file.

    cd /usr/local/zookeeper-3.4.10/conf
    mv zoo_sample.cfg zoo.cfg
    vim zoo.cfg
    dataDir=/usr/local/zookeeper-3.4.10/zkData
    #######################cluster##########################
    server.1=bigdata111:2888:3888
    server.2=bigdata112:2888:3888
    server.3=bigdata113:2888:3888
    

    Server.A=B:C:D.
    A is a number, indicating the number of the server;
    B is the ip address of the server;
    C is the port for the server to exchange information with the Leader server in the cluster;
    D is in case the Leader server in the cluster hangs up, you need a The port is used to re-election and a new Leader is elected, and this port is the port used to communicate between servers during the election.

    Configure a file myid in cluster mode. This file is in the dataDir directory. There is a data in this file that is the value of A. Zookeeper reads this file when it starts, and compares the data in it with the configuration information in zoo.cfg to judge Which server is it?

  4. Create a myid file in the /usr/local/zookeeper-3.4.10/zkData directory and add the number corresponding to the server.

    vim myid
    1
    
  5. Copy Zookeeper to the other two machines bigdata112 and bigdata113.

    scp -r zookeeper-3.4.10/ root@bigdata112:/usr/local
    scp -r zookeeper-3.4.10/ root@bigdata113:/usr/local
    
  6. Modify myid on the other two machines.

    Bigdata112 is changed to 2, and bigdata113 is changed to 3.

  7. Start ZK separately.

    [root@bigdata111 zookeeper-3.4.10]# bin/zkServer.sh start
    [root@bigdata112 zookeeper-3.4.10]# bin/zkServer.sh start
    [root@bigdata113 zookeeper-3.4.10]# bin/zkServer.sh start
    
  8. Check the status.

    [root@bigdata111 zookeeper-3.4.10]# bin/zkServer.sh status
    JMX enabled by default
    Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg
    Mode: follower
    [root@bigdata112 zookeeper-3.4.10]# bin/zkServer.sh status
    JMX enabled by default
    Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg
    Mode: leader
    [root@bigdata113 zookeeper-3.4.5]# bin/zkServer.sh status
    JMX enabled by default
    Using config: /usr/local/zookeeper-3.4.10/bin/../conf/zoo.cfg
    Mode: follower
    

    It can be seen that bigdata112 is the Leader, while bigdata111 and bigdata113 are Followers.

Guess you like

Origin blog.csdn.net/u011886447/article/details/104885074