Two, Linux install Zookeeper

      This article describes the installation of Zookeeper from two parts, namely local mode installation and deployment and distributed installation and deployment. Pay attention to the column "Broken Cocoon and Become a Butterfly- Zookeeper " to view Zookeeper related series of articles~


table of Contents

1. Deploy Zookeeper in local mode

1.1 Prerequisites

1.2 Install Zookeeper

Two, the configuration parameters in zoo.cfg

Three, distributed installation of Zookeeper

3.1 Modify the zoo.cfg configuration file

3.2 Create myid file

3.3 distribute Zookeeper

3.4 Start the cluster and view the cluster status


 

1. Deploy Zookeeper in local mode

1.1 Prerequisites

       1. Install jdk

       2. Upload the Zookeeper tar package

1.2 Install Zookeeper

       1. Unzip Zookeeper to the specified directory

[root@master software]# tar -zxvf ./zookeeper-3.4.10.tar.gz -C ../modules/

       2. Modify the configuration file in the conf directory

[root@master conf]# pwd 
/opt/modules/zookeeper-3.4.10/conf
[root@master conf]# cp ./zoo_sample.cfg zoo.cfg

       Edit the zoo.cfg file as follows:

       3. Create dataDir corresponding to the directory

       4. Start Zookeeper

[root@master zookeeper-3.4.10]# bin/zkServer.sh start

Two, the configuration parameters in zoo.cfg

       1. 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. It is used for the heartbeat mechanism and sets the minimum session timeout time to twice the heartbeat time. (The minimum timeout of session is 2*tickTime)

       2. initLimit = 10: LF initial communication time limit. The maximum number of heartbeats (the number of tickTimes) that can be tolerated during the initial connection between the Follower server in the cluster and the Leader leader server. Use it to limit the time limit for the Zookeeper server in the cluster to connect to the Leader.

       3. syncLimit=5: LF synchronous communication time limit. The maximum response time unit between Leader and Follower in the cluster. If the response exceeds syncLimit * tickTime, Leader thinks that the follower is dead and deletes the follower from the server list.
       4. dataDir: data file directory + data persistence path. Mainly used to save data in Zookeeper.
       5. clientPort=2181: client connection port. The port that listens for client connections.

Three, distributed installation of Zookeeper

3.1 Modify the zoo.cfg configuration file

server.1=master:2888:3888
server.2=slave01:2888:3888
server.3=slave02:2888:3888

       Among them, (1) The number after server indicates which server is this number. Configure a file myid in cluster mode. This file is in the dataDir directory. There is a data in this file that is the number value of the server. Zookeeper reads this file when it starts, and compares the data with the configuration information in zoo.cfg. Determine which server it is. (2) Master, slave, etc. represent the address of the server. (3) 2888 represents the port for the server Follower to exchange information with the Leader server in the cluster. (4) 3888 represents that in case the Leader server in the cluster hangs up, a port is needed to re-elect and select a new leader. This port is used to communicate with each other when the election is executed.

3.2 Create myid file

       Create a myid file and put the server number in the file:

3.3 distribute Zookeeper

       Distribute the configured Zookeeper to slave nodes.

       Note: After the distribution is completed, the myid of the slave node needs to be modified.

3.4 Start the cluster and view the cluster status

bin/zkServer.sh start
bin/zkServer.sh status

 

       This is the end of this article. If you have any problems during this process, please leave a message and let me see what problems you have encountered~

Guess you like

Origin blog.csdn.net/gdkyxy2013/article/details/108460883