Zookeeper cluster installation method, zookeeper Cluster

Source: Internet
Author: User

Zookeeper cluster installation method, zookeeper Cluster
1. First, prepare three slave servers.

2. Install JDK

The execution of zookeeper requires JDK support. Therefore, JDK needs to be installed when zookeeper is just installed. For details about how to install JDK in Linux, refer to my blog: Install JDK easily and quickly.

3. Install zookeeper

(First install on one server, then copy it to another server, and then simply modify the attributes)

Here we have prepared the three servers, hadoop05 and 06,07. First, we have uploaded the binary installation package of zookeeper to the too server hadoop05. Here we provide a click to open the link;

A. decompress the package and move it to the/app directory.

tar -zxvf zookeeper-3.4.5.tar.gz -C /app

B. modify the/etc/profile file and add the home path and bin of zookeeper to the system environment variable. This is to help us start the zookeeper Server Anywhere in linux; the root permission is required for execution.

sudo vi /etc/profile

In vim mode, run the modify command at the bottom to view the home path of zookeeper.

:cd /app/zookeeper-3.4.5/

Use the following command to make the preceding configuration take effect. This command does not require the root permission.

 source /etc/profile

C. Modify $ ZK_HOME/conf/zoo_sample.cfg

mv zoo_sample.cfg zoo.cfg
Note that many people are prone to errors in this area. Changing zoo. cfg to zoo_cfg causes an error when starting the zookeeper server. This problem is very difficult to find out!

From the picture above, we can easily see that zookeeper configures this information for us by default during pre-installation, but it is far from enough in a real production environment. Here we can modify two things:

(1) dataDir. The default path here is/tmp/zookeeper.

In Linux, the/tmp directory is used to store some temporary files. Here, zookeeper also uses this function to store some file information temporarily generated by zookeeper here by default, but it is not convenient for our development and management. We recommend that you create a data directory under the home Directory of zookeeper to store the information of myid in the cluster, and then in zoo. the dataDir attribute of cfg points to the data path.

DataDir = $ ZK_HOME/data

(2) server name and address: cluster information (server number, server address, LF communication port, election port)
The writing format of this configuration item is special. The rules are as follows:
Server. N = YYY: A: B

server.1=hadoop05:2888:3888server.2=hadoop06:2888:3888server.3=hadoop07:2888:3888

Configure the Host Name and IP address ing. Don't forget

(3) create a data directory and configure myid

mkdir $ZK_HOME/datacd $ZK_HOME/dataecho 1 > myid
4. Copy the zookeeper file to another server.
scp -r $ZK_HOME hadoop06:/app/scp -r $ZK_HOME hadoop07:/app/sudo scp /etc/profile hadoop06:/etc/profilesudo scp /etc/profile hadoop07:/etc/profile

5. Change the myid number (1) 06 under the data Directory of to 2 and 07 to 3.
6. Starting the Cluster Environment zookeeper does not want to start a service like hdfs, it will help you automatically start other machines in the cluster, and we need to go to other machines to start it ourselves.
Start the zookeeper cluster in the response at, 07
ZkService. sh startzkService. sh status # view the server status
When you start a server and check that it only works on one server, it is always in this single-host status.
Mode: standalone
We start other machines, and then we can see that there is a leader and Two flower.

From the above we can easily see that hadoop06 is a leader. The cluster is successfully created!

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.