Zookeeper actual combat-the cluster environment constructs

Source: Internet
Author: User
Tags time interval zookeeper

Zookeeper Distributed Services Framework is a subproject of the Apache Hadoop, it is Google's chubby an open source implementation, is mainly used to solve some of the data management problems frequently encountered in the distributed application, such as: Unified Naming Service, State Synchronization service, cluster management, Management of distributed application configuration items.
Zookeeper are heavily used in distributed systems, such as Hadoop, Storm, and Kafka systems.
This paper briefly records the construction process of zookeeper cluster environment under Linux environment for reference. prepare for the three CentOS servers, their IP addresses are 172.18.19.206,172.18.19.207 and 172.18.19.208 zookeeper 3.4.8 installation Zookeeper

Before installing the zookeeper you need to install the JDK, this article assumes that you have installed the JDK and configured the environment variables.
1. Download Zookeeper
Click here to download the latest stable version of zookeeper, I download the installation zookeeper the latest stable version of 3.4.8.
2. Decompression

[Root@w206-ops-docker1 zookeeper]# TAR-ZXVF zookeeper-3.4.8.tar.gz
Configuration

1. Create Zoo.cfg
Zookeeper configuration file in the Conf directory, you just have to zoo_sample.cfg copy one name to Zoo.cfg, and then modify the configuration as needed, because zookeeper will find this file as the default profile at startup.

[Root@w206-ops-docker1 zookeeper-3.4.8]# CP conf/zoo_sample.cfg conf/zoo.cfg

Zoo.cfg complete configuration is as follows:

# the number of milliseconds of each tick ticktime=2000 # The number of ticks that initial sy Nchronization phase can take initlimit=10 # The number of ticks that can pass between # Sending a request and getting a A
Cknowledgement synclimit=5 # The directory where the snapshot is stored. Datadir=/home/hadoop/zookeeper/zookeeper-3.4.8/data # The port at which the clients'll connect clientport=2181 # server Config server.1=172.18.19.206:2888:3888 server.2=172.18.19.207:2888:3888 server.3=172.18.19.208:2888:3888 

The parameter meaning is as follows: Ticktime: This time is the time interval between the zookeeper server or between the client and the server to maintain heartbeat, namely each ticktime
Time will send a heartbeat. DataDir: As the name implies is zookeeper save the data directory, by default, zookeeper will write the data log file also saved in this directory. ClientPort: This port is the port where the client connects to the zookeeper server, and zookeeper listens to the port to accept the client's access request. Initlimit: This configuration entry is used to configure zookeeper to accept clients (the client is not a user connection in this case zookeeper
The client of the server, but the Zookeeper server cluster connected to the Leader Follower
Server) The maximum number of heartbeat intervals that can be tolerated when a connection is initialized. When there is more than 10 heartbeats (i.e. ticktime) length of time zookeeper
The server has not received return information from the client, indicating that the client connection failed. The total length of time is 5*2000=10 seconds Synclimit: This configuration item identifies Leader and Follower send messages between the length of the request and the answer, the longest can not exceed the number of
Ticktime the length of time, the total length of time is 2*2000=4 second server. A=b:c:d: Where A is a number indicating what the server is, and B is the IP address of the server;
Represents the port in which the server exchanges information with the Leader server in the cluster; D means in case of Leader in the cluster
The server hangs up and needs a port to rerun the election and elect a new
Leader, and this port is the port that is used to communicate with each other when the election is performed. If the configuration of the pseudo cluster, because B is the same, so different zookeeper
Instance communication port numbers cannot be the same, so assign them a different port number.

2. Create myID files
In addition to modifying the Zoo.cfg configuration file, a file myID is configured in cluster mode, which is in the DataDir directory.

Create the Zookeeper data directory as follows:

[Root@w206-ops-docker1 zookeeper-3.4.8]# mkdir data
[root@w206-ops-docker1 zookeeper-3.4.8]# CD data

Create myID file with 1 content, note that this value changes with server (remains unique)

[Root@w206-ops-docker1 data]# VI myID

At this point, the zookeeper installed & configured on this machine is complete. Next, we'll just have the/home/hadoop/zookeeper/configured on the 172.18.19.206 machine. The zookeeper-3.4.8 directory is respectively SCP to the corresponding directory on the 172.18.19.207 and 172.18.19.208 machines, and then the contents of the Zookeeper-3.4.8/data/myid on it are modified to 2 and 3. Start Zookeeper

The following starts the Zookeeper service process:

[Root@w206-ops-docker1 zookeeper]# cd zookeeper-3.4.8
[Root@w206-ops-docker1 zookeeper-3.4.8]# bin/zkserver.sh Start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.