ZooKeeper (2) – Installation and Configuration

1. Download

https://zookeeper.apache.org/

< img alt="Share a picture" src="/wp-content/uploads/images/opensource/zookeeper/1626812913269.png" >

Share a picture

share picture

2. Local mode installation

1. Preparation before installation

(1) Install Jdk

(2) Copy Zookeeper installation package to Linux system

(3) Unzip to the specified directory

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

2. Configuration modification

(1) Change /opt/module/zookeeper- Copy zoo_sample.cfg under 3.4.10/conf as zoo.cfg;

cp zoo_sample.c fg zoo.cfg

(2) Open the zoo.cfg file and modify the dataDir path:

vim zoo.cfg

Modify the following content:

dataDir=/opt/module/zookeeper-3.4.10/zkData

< p>(3) Create a zkData folder in the directory /opt/module/zookeeper-3.4.10/

 mkdir zkData

(4) Modify the log path and enter the /bin directory

vim zkEnv.sh

ZOO_LOG_DIR="/opt/module/zookeeper-3.4.10/logs"

pre>

3. Operate Zookeeper

(1) Start Zookeeper

bin/zkServer.sh start

(2) Check whether the process is started

jps

< /div>

(3) View status:

bin/zkServer.sh status

pre>

(4) Start the client

bin/zkCli.sh 

(5) Exit the client:

quit

(6) Stop Zookeeper

bin/zkServer.sh stop

3. Interpretation of configuration parameters

1. tickTime = 2000: the number of communication heartbeats, the heartbeat time between Zookeeper server and client, in milliseconds
The basic time used by Zookeeper, the time interval for maintaining heartbeats between servers or between client and server, that is, each tickTime time A heartbeat will be sent, and the time unit is milliseconds.
It is used for the heartbeat mechanism, and set the minimum session timeout to twice the heartbeat time. (The minimum timeout of session is 2*tickTime)

2. initLimit =10: LF initial communication time limit Time limit for connecting to Leader.

3. syncLimit =5: LF synchronization communication time limit
The maximum response time unit between Leader and Follower in the cluster. If the response exceeds syncLimit * tickTime, the 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. Cluster installation

< span style="font-size: 14pt">1. Cluster planning

Deploy on hadoop100, hadoop101, and hadoop102, start three virtual machines

2. Configure myid file

1) Create a myid file in the /opt/module/zookeeper-3.4.10/zkData directory of the hadoop100 machine , Add the corresponding number 0 of the server

echo >> 0 myid

3. Configure the zoo.cfg file and add the following content at the end of the file

server.0=hadoop100:2888:3888
server.1=hadoop101:2888:3888
server.2=hadoop102:2888:3888

Interpretation of configuration parameters

server.A=B:C:D .

A is a number, indicating which server is this number;

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

B is the address of this server;

C is the port for this server's Follower to exchange information with the Leader server in the cluster ;

D is in case the Leader server in the cluster is down, a port is needed to re-election, and a new leader is selected, and this port is used to perform the election When the server communicates with each other port.

4). Distribute the configuration file to hadoop101, hadoop102, and modify the myid file of each machine

xsync /opt/module/zookeeper- 3.4.10/

#Respectively modify to 1 and 2
vim myid

How to install a virtual machine, how to configure a cluster, how to distribute files, please refer to the article under Hadoop series

4. Cluster operation

1) Start Zookeeper separately

bin/zkServer.sh start

2)Check status

bin/zkServer.sh status

If you have two followers and a leader, it means success

If you can’t start up, you can check log file

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

< /p>

cp zoo_sample.cfg zoo.cfg

vim zoo.cfg< /pre>

dataDir=/opt/module/zookeeper-3.4.10/zkDat a

mkdir zkData

vim zkEnv.< span style="color: #0000ff">sh

ZOO_LOG_DIR="/opt/module/zookeeper-3.4.10/logs"

< /p>

bin/zkServer.sh start

jps

< /p>

bin/zkServer.sh status

bin/zkCli.sh

quit

bin/zkServer.sh stop

1. tickTime = 2000: the number of communication heartbeats, the heartbeat time between Zookeeper server and client, in milliseconds
The basic time used by Zookeeper, the time interval for maintaining heartbeats between servers or between client and server, that is, each tickTime time A heartbeat will be sent, and the time unit is milliseconds.
It is used for the heartbeat mechanism, and set the minimum session timeout to twice the heartbeat time. (The minimum timeout of session is 2*tickTime)

2. initLimit =10: LF initial communication time limit Time limit for connecting to Leader.

3. syncLimit =5: LF synchronization communication time limit
The maximum response time unit between Leader and Follower in the cluster. If the response exceeds syncLimit * tickTime, the 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.

echo >> 0 myid

server.0=hadoop100:2888:3888
server.1=hadoop101:2888:3888
server.2=hadoop102:2888:3888

xsync /opt/module/zookeeper- 3.4.10/

#Respectively modify to 1 and 2
vim myid

< p>

bin/zkServer.sh start

bin/zkServer.sh status

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4769 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.