Zookeeper (two) installation

Zookeeper (two) installation

Local mode installation

Preparation before installation

  1. Install jdk

  2. Copy apache-zookeeper-3.6.0-bin.tar.gz to the opt directory

  3. Unzip the installation package

    tar -zxvf apache-zookeeper-3.6.0-bin.tar.gz
    

Insert picture description here

  1. Rename

    mv apache-zookeeper-3.6.0-bin zookeeper
    

Insert picture description here

Configuration modification

Create the zkData and zkLog directories on the /opt/zookeeper/ directory

mkdir zkData
mkdir zkLog

Insert picture description here

Enter the path /opt/zookeeper/conf, copy a zoo_sample.cfg file and name it zoo.cfg

cp zoo_sample.cfg zoo.cfg

Insert picture description here

Edit the zoo.cfg file and modify the dataDir path

dataDir=/opt/zookeeper/zkData
dataLogDir=/opt/zookeeper/zkLog

Insert picture description here

Operate Zookeeper

Start Zookeeper

./zkServer.sh start

Insert picture description here

Check whether the process is started

jps

Insert picture description here

QuorumPeerMain: is the startup entry class of the zookeeper cluster, which is used to load the configuration to start the QuorumPeer thread

Check status

./zkServer.sh status

Insert picture description here

Start the client

./zkCli.sh

Insert picture description here

Exit the client

quit

Insert picture description here

Interpretation of configuration parameters

The meaning of the parameters in the zoo.cfg configuration file in Zookeeper is interpreted as follows:

  • tickTime = 2000: the number of communication heartbeats, the heartbeat time between Zookeeper server and client, in milliseconds

    • The basic time used by Zookeeper is the time interval between servers or between the client and the server to maintain a heartbeat, that is, a heartbeat will be sent every tickTime, and the time unit is milliseconds.
  • initLimit =10: LF initial communication time limit

    • The maximum number of heartbeats that can be tolerated at startup between the Follower server and Leader server in the cluster
    • 10*2000 (10 heartbeat time) If the leader and follower do not send out heartbeat communication, it is regarded as an invalid connection, and the leader and follower are completely disconnected
  • syncLimit =5: LF synchronization communication time limit

    • After the cluster is started, the maximum response time unit between Leader and Follower. If the response exceeds syncLimit *tickTime->10 seconds, Leader thinks that the follower is dead and deletes the follower from the server list
  • dataDir: data file directory + data persistence path

    • Mainly used to save data in Zookeeper.
  • dataLogDir: log file directory

  • clientPort =2181: client connection port

    • The port that listens for client connections.

Guess you like

Origin blog.csdn.net/weixin_49741990/article/details/112502589