Zookeeper installation

MelodyYN 2022-02-13 08:26:30 阅读数:283

zookeeper installation

Zookeeper install

1. Download and install

In the installation JDK1.8 Based on

adopt https://zookeeper.apache.org/releases.html download

tar -zxvf zookeeper-3.5.7.tar.gz -C /opt/module/

2. Modify the configuration file

  • take /opt/module/zookeeper-3.5.7/conf Under this path zoo_sample.cfg It is amended as follows zoo.cfg

    mv zoo_sample.cfg zoo.cfg
  • Create this path

    mkdir -p /opt/module/zookeeper-3.5.7/zkData
  • stay /opt/module/zookeeper-3.5.7/zkData Create one in the directory myid The file of

  • edit myid file

    #3 Table cannot be repeated ,hadoop102 by 2,hadoop103 by 3,hadoop104 by 4
  • Synchronize to other nodes , And modify it to the corresponding content

  • modify zoo.cfg, Specify the data storage location



    A It's a number , Which server is this ;

    Configure a file in cluster mode myid, This file is in dataDir Under the table of contents , One of the data in this file is A Value ,Zookeeper Read this file at startup , Get the data and zoo.cfg The configuration information in it is compared to determine which is server.

    B It's the address of this server ;

    C It's this server Follower And... In the cluster Leader Servers exchange information The port of ;

    D In case the server in the cluster hangs up , Need a port to redo The election , Pick a new one , And this port is the port that the servers communicate with each other during the election

  • take zoo.cfg Synchronize to other nodes

  • Configure environment variables

    export ZOOKEEPER_HOME=/opt/module/zookeeper-3.5.7

    Distribute and source

  • Script group ZooKeeper

    if [ $# -lt 1 ]
    echo "No Args Input"
    case $1 in
    for i in hadoop102 hadoop103 hadoop104
    echo "==================$i=================="
    ssh $i /opt/module/zookeeper-3.5.7/bin/zkServer.sh start
    for i in hadoop102 hadoop103 hadoop104
    echo "==================$i=================="
    ssh $i /opt/module/zookeeper-3.5.7/bin/zkServer.sh status
    for i in hadoop102 hadoop103 hadoop104
    echo "==================$i=================="
    ssh $i /opt/module/zookeeper-3.5.7/bin/zkServer.sh stop
    for i in hadoop102 hadoop103 hadoop104
    echo "==================$i=================="
    ssh $i /opt/module/zookeeper-3.5.7/bin/zkServer.sh status
    echo "Args Error"

Interpretation of configuration file parameters

  1. tickTime =2000: The number of communication heartbeat ,Zookeeper Server and client heartbeat time , Unit millisecond

    Zookeeper Basic time used , Time interval between servers or between clients and servers to maintain heartbeat , That is, every one of them tickTime Time will send a heartbeat , Time is measured in milliseconds .

    It's used for the heartbeat mechanism , And set the smallest session The timeout is twice the heartbeat time .(session The minimum timeout for is 2*tickTime)

  2. initLimit =10:LF Initial communication time limit

    In the cluster Follower Follower server and Leader Between leaders and servers On initial connection The maximum number of heartbeats that can be tolerated (tickTime The number of ), Use it to limit the Zookeeper The server is connected to Leader Time limit of .

  3. syncLimit =5:LF Synchronous communication time limit

    In the cluster Leader And Follower The unit of maximum response time between , If the response exceeds syncLimit*tickTime,Leader Think Follwer Die , Remove... From the server list Follwer.

  4. dataDir: Data file directory + Data persistence path

    It is mainly used to preserve Zookeeper Data in .

  5. clientPort =2181: Client connection port

    Listen for the port of the client connection .

3. start-up ZooKeeper

zkServer.sh start
zkServer.sh status

Use jps Check the startup

4. Start client

copyright:author[MelodyYN],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/02/202202130826278421.html