Amazon Linux System installation Configuration zookeeper cluster

Source: Internet
Author: User
Tags zookeeper

Brief introduction:

Zookeeper is a distributed, open source distributed application Coordination Service that is an open source implementation of Google's chubby and an important component of Hadoop and HBase. It is a software that provides consistent services for distributed applications, including configuration maintenance, domain name services, distributed synchronization, group services, and so on.

The goal of zookeeper is to encapsulate complex and error-prone services that provide users with easy-to-use interfaces and performance-efficient, robust systems.


Zookeeper mode:

Standalone Standalone mode:

There is only one zookeeper service instance that is not guaranteed to be highly reliable and resilient, can be used in test environments, and is not recommended for production environments.


Distributed cluster Mode:

With multiple zookeeper instances running, it is recommended that more than one ZK instance be on a different server. Data is constantly synchronized between different zookeeper instances in the cluster. More than half of the instances remain normal operation, the ZK service will be able to run normally, for example: There are 5 ZK instances, hanging 2, and 3 remaining, still can work normally, if there are 6 ZK instances, 3 are hung, it will not work properly.


Pseudo-Cluster mode:

In simple terms, the cluster pseudo-distribution mode is the zookeeper service that simulates the cluster under a single machine.


This article mainly explains the cluster mode installation deployment



First, installation environment

1. Operating system: Amazon Linux (current version based on CENTOS6 core)

2, jdk-1.7.9

3, zookeeper-3.4.8


Ii. Installation of JDK

Installing zookeeper requires the JDK to be installed first,

Install JDK Reference Site blog http://linuxtech.blog.51cto.com/3670088/1706792


Third, modify the Hosts file

Host name-to-IP address mapping configuration

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 the zookeeper cluster is configured, the mapping of the host to the IP address of each node should be configured to map information of the other nodes in the cluster.

For example, for the configuration of each node in my zookeeper cluster, take slave-01 as an example, the/etc/hosts content is as follows:

192.168.0.101 slave-1

192.168.0.102 slave-2

192.168.0.103 slave-3

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 is started, a leader will be selected first, and in the leader election process, a node that satisfies the election can become leader.


Iv. installation and configuration of zookeeper

To http://zookeeper.apache.org/releases.html to download the zookeeper, it is recommended to choose stable version, that is stable.


Tar zxvf zookeeper-3.4.8.tar.gz-c/export/server/

cd/export/server/

MV Zookeeper-3.4.8/zookeeper

CD zookeeper/

CP Conf/zoo_sample.cfg Conf/zoo.cfg

Mkdir-p/export/data/zookeeper/


Modifying the Zoo.cfg configuration file

Sed-i ' s/datadir=\/tmp\/zookeeper/datadir=\/export\/data\/zookeeper/' conf/zoo.cfg

echo "

> server.1=slave-1:2888:3888

> server.2=slave-2:2888:3888

> server.3=slave-3:2888:3888

> ' >> conf/zoo.cfg


V. Configuring environment Variables for zookeeper

Cat >>/etc/profile <<eof

Export Zookeeper_home=/export/server/zookeeper

Export path= $PATH: $ZOOKEEPER _home/bin

Eof


Make it effective

Source/etc/profile


Six: Remote replication distribution installation files

The above has been configured on a machine slave-01 to complete the zookeeper, you can now remotely copy the configured installation files to each node in the cluster corresponding to the directory:


Seven: Set myID

Under the directory specified by our ZOO.CFG configuration DataDir, create a myID file that contains a number that identifies the current host, conf/ The number of x in the server.x configured in the Zoo.cfg file is entered in the myID file, for example:

[[Email protected]/]echo "1" >/export/data/zookeeper/myid

[[Email protected]/]echo "2" >/export/data/zookeeper/myid

[[Email protected]/]echo "3" >/export/data/zookeeper/myid


Eight, start zookeeper cluster

On each node of the zookeeper cluster, execute the script that starts the Zookeeper service as follows:

chmod +x-r bin/

CD bin/

./zkserver.sh Start


To view the boot log:

TAIL-500F Zookeeper.out


Nine, view status

To see if the zookeeper cluster is started

./zkserver.sh Status

ZooKeeper JMX enabled by default

Using config:/export/server/zookeeper/bin/. /conf/zoo.cfg

Mode:follower

The display of the leader is:

ZooKeeper JMX enabled by default

Using config:/export/server/zookeeper/bin/. /conf/zoo.cfg

Mode:leader

Viewing the startup status of zookeeper

echo Ruok | NC 192.168.0.101 2181

Console output: Imok



Ten, testing

You can connect to one of the servers via the Zkcli.sh-server IP, and then you can control ZK with interactive commands



Finish

This article is from the "Small Five Car God" blog, please be sure to keep this source http://linuxtech.blog.51cto.com/3670088/1775378

Amazon Linux System installation Configuration 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.