Installation of the Zookeeper cluster

Source: Internet
Author: User

  Name impliesZookeeperIs the zoo keeper, he is used to controlHadoop(elephant),Hive (Bee),Pig (Piglet)the administrator,Apache Hbaseand theApache SOLRdistributed clusters are used in theZookeeper;Zookeeper:is a distributed, open-source program coordination Service that isHadoopa subproject under the project。

 First, the main functions of zookeeper are as follows:

1. Configuration Management

In addition to the code in our application, there are a number of configurations. such as database connections. In general, we are using configuration files to introduce these configuration files in code. But it's a good idea to use a configuration file when we have only one configuration, one server, and it's not often modified, but if we have a lot of configuration, there are many servers that need this configuration, and it might be dynamic to use a configuration file. At this point, we often need to find a way to centrally manage the configuration, where we have modified the configuration in this centralized location, and all interested in this configuration can be changed. For example, we can put the configuration in the database, and then all the services that need to be configured go to this database to read the configuration. However, because many of the services are very dependent on this configuration, the service required to provide configuration services in a centralized setting is highly reliable. Generally we can use a cluster to provide this configuration service, but with the cluster to improve the reliability, how to ensure that the configuration in the cluster consistency? This is the time to use a service that implements a consistency protocol.Zookeeperis this service, it usesZabThis consistency protocol to provide consistency. Now there are many open source projects that useZookeeperto maintain the configuration, such as inHBase, the client is connected to aZookeeper, to obtain the necessaryHBasethe configuration information for the cluster before you can proceed further. There's also a message queue in open sourceKafka, also useZookeeperto maintainBrokerthe information. In theAlibabaOpen-SourceSOAFrameDubboalso widely used in theZookeepermanage some configurations to implement service governance.

2. Name Service

Name Service This is a good understanding. For example, in order to access a system through the network, we need to know each other's IP address, but the IP address is very unfriendly to people, this time we need to use the domain name to access. But the computer cannot be a domain name. What do we do? If we have a domain name to IP address mapping in each machine, this can solve some of the problems, but what if the domain name corresponding to the IP has changed? So we have the DNS this thing. We only need to access a well-known (known) Point and it will tell you what the IP address of the domain corresponds to . There are a lot of these problems in our application, especially when we have a very large number of services, and it will be very inconvenient if we save the address of the service locally, but if we only need access to a well-known access point where we provide a unified portal, it will be much easier to maintain.

3. Distributed lock

In fact, the first article has introduced the zookeeper is a distributed coordination service. This allows us to take advantage of the zookeeper fail over to another service. This is done in many distributed systems, and this design has a more pleasant name called leader election (Leader Span style= "font-family: the song Body;" > election " hbase master

4. Cluster Management

In distributed clusters, often due to various reasons, such as hardware failure, software failure, network problems, some nodes will enter and exit. There are new nodes to join in, and there are old nodes exiting the cluster. At this point, other machines in the cluster need to perceive this change and then make corresponding decisions based on that change. For example, we are a distributed storage system, there is a central control node responsible for the allocation of storage, when there are new storage in the current state of the cluster to allocate storage nodes. At this point we need to dynamically perceive the current state of the cluster. There are, for example, a distributedSOAarchitecture, a service is provided by a cluster, and when a consumer accesses a service, a mechanism is needed to discover which nodes are now available for the service(This is also called service discovery, such asAlibabaOpen-SourceSOAFrameDubboit uses aZookeeperas the underlying mechanism for service discovery). and open source.Kafkathe queue is based onZookeeperas aCosnumerUp and down line management.

Second, Zookeeper cluster Installation

  1. Download the installation package

  http://apache.fayea.com/zookeeper/zookeeper-3.4.6/

2. Unzip the package

3. Create the Solrclude folder and copy the extracted zookeeper package to the Solrclude folder

  

4. Copy the zookeeper-3.4.6 to /usr/local/solrcloud, copy the three copies and change the directory name to zookeeper 1,zookeeper2,zookeeper3

  

5. Go to the Zookeeper1 folder and create the data directory. and Create a myid file in the data directory with the content "1" (echo 1 >> data/ myID).

  

6. go to the Conf folder and rename zoo_sample.cfg to zoo.cfg

  

7. Modify zoo.cfg

Datadir=/usr/local/solrcloud/zookeeper1/data

clientport=2181(zookeeper2 in 2182,zookeeper3 2183 )

Add to:

server.1=192.168.198.130:2881:3881

server.2=192.168.198.130:2882:3882

server.3=192.168.198.130:2883:3883

  

8. Change the settings in zookeeper2,3 to the fourth step.

Zookeeper2:

myID content is 2

Datadir=/usr/local/solrcloud/zookeeper2/data

clientport=2182

Zookeeper3:

    myID content is 3

Datadir=/usr/local/solrcloud/zookeeper3/data

clientport=2183

9. Start three zookeeper, view status

start three zookeeper/usr/local/solrcloud/zookeeper1/bin/zkserver.sh start/usr/local/solrcloud/ zookeeper2/bin/zkserver.sh start/usr/local/solrcloud/zookeeper3/bin/zkserver.sh start view cluster status:/ usr/local/solrcloud/zookeeper1/bin/zkserver.sh status/usr/local/solrcloud/zookeeper2/bin/  zkserver.sh Status/usr/local/solrcloud/zookeeper3/bin/zkserver.sh status

Installation of the Zookeeper cluster

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.