Zookeeper distributed mode installation in Ubuntu (zookeeper cluster)

Source: Internet
Author: User
Tags file copy solr zookeeper port number

Background:

Install zookeeper on three servers, each of which will install SOLR in the future on three servers, and the zookeeper installed here is for use in SOLR (to coordinate SOLR configuration files on three servers, SOLR data, and so on).


Profile:

The first thing to be clear is that the zookeeper cluster is an independent distributed coordination Service cluster, the meaning of "independent" is that if you want to use zookeeper to achieve the coordination and management of distributed applications, simplify coordination and management, any distributed applications can be used.

There are two key roles in the Zookeeper cluster: leader and follower. All nodes in the cluster serve as a whole to the distributed application, and each node in the cluster is connected to each other, so when configuring the zookeeper cluster, the mapping information of the other nodes in the cluster is configured in the zoo.cfg of each node.

Zookeeper employs an election algorithm called leader election. In the whole cluster running process, there is only one leader, the other is follower, if the zookeeper cluster in the process of leader the problem, the system will use this algorithm to re-select a leader. Therefore, the above mappings must be configured to ensure that each node is connected to each other. When the zookeeper cluster starts, a leader will be selected first, and in the leader election process, a node that satisfies the election algorithm can become leader.


First, installation environment

1, install the JDK, the latest version of the zookeeper requires more than 1.8 versions of the JDK.

2, download zookeeper installation package, it is recommended to download the latest version, download tar.gz format package, download address: http://apache.fayea.com/zookeeper/


Second, decompression

1, in the download directory to extract: Tar-zxf zookeeper-3.4.3.tar.gz

2, extracted after the directory: zookeeper-3.4.3, can be zookeeper-3.4.3/conf directory zoo_sample.cfg file copy, named as: Zoo.cfg

3. Modify the contents of Zoo.cfg to:

3.1, wherein, the black smear part is three server's intranet IP address respectively;

The 3.2, 2888, 2889, 2890 port numbers are the ports of communication between the zookeeper services, representing the ports that the server exchanges information with the Leader servers in the cluster;

The 3.3, 3888, 3889, 3890 port numbers indicate that in case the Leader server in the cluster is hung up, a port is needed to re-elect a new Leader, which is the port that the server communicates with each other when the election is performed. If it is a pseudo-cluster configuration, because the IP is the same, so different Zookeeper instance communication port number can not be the same, so they should be assigned a different port number;

3.4, Ticktime=2000,zookeeper server heartbeat time, unit milliseconds;

3.5, datadir=/data/zkdata/1/, data persistence path, must be built in advance, Zkdata directory sub-directory "1" corresponds to "1" in Server.1, this IP belongs to the first server, and need to create a file under the directory "1" myID ", myID's file content only fill" 1 "

Similarly, after configuring the first server, copy the entire directory "zookeeper-3.4.3" to the second, third server, respectively, and change the value of DataDir to:/data/zkdata/2/,/data/zkdata/3/

and the corresponding under the directory "2" to create the file "myID", the contents of the file is only filled "2", under the directory "3" to create the file "myID", the contents of the file is only filled "3"

3.6, clientport=2181 Client Connection Zookeeper service port number;

3.7, the maximum response time unit between synclimit=2 leader and follower, response more than Synclimit*ticktime,leader think Follwer dead, remove Follwer from the server list.

3.8. Initlimit=5 vote to elect the initial time of the new leader


Third, start and test zookeeper

1, respectively in three servers in the zookeeper-3.4.3/bin/directory execution:./zkserver.sh start

2, enter the JPS command to view the process, wherein, Quorumpeermain is the zookeeper process, indicating the success of the launch;

3, because the zookeeper cluster start, each node is trying to connect to the other nodes in the cluster, the first start must not be connected to the back of the boot, so the log appears in the exception "[workersender[myid=1]:quorumcnxmanager@382 ]-Cannot open channel to 2 at election address * * * is normal, and other nodes will have similar problems, until the last node starts without this exception.

4. You can also view the roles of each node in the cluster (either leader, or follower), as shown below, in the zookeeper-3.4.3 directory of each node in the Zookeeper cluster./BIN/ZKSERVER.SH status

5, in addition, can be connected to the zookeeper cluster via client script. For the client, zookeeper is a whole (ensemble), and connecting to the zookeeper cluster actually feels like an entire cluster of services, so you can establish a connection to the service cluster at any one of the nodes. For example, execute under the zookeeper-3.4.3 directory on any one node./bin/zkcli.sh-server node IP address: 2181


Iv. Cessation of Zookeeper services

1. Execute in the zookeeper-3.4.3 directory of each node./bin/zkserver.sh stop

2. If you want to restart the zookeeper service, execute it in the zookeeper-3.4.3 directory of each node./bin/zkserver.sh restart


V. Zookeeper Common Client commands

The Zookeeper command-line tool is similar to a Linux shell environment, but it is certainly less powerful than the shell, but with it we can simply access the zookeeper, create data, modify data, and so on. Using the Zkcli.sh-server node ip:2181 to connect to the ZooKeeper service, the system outputs ZooKeeper related environment and configuration information after the connection is successful.

Frequently used commands can refer to Links: http://blog.csdn.net/xiaolang85/article/details/13021339

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.