Big data: From Getting Started to XX (vi)

Source: Internet
Author: User

What is zookeeper, see Zookeeper official website how to say:

Apache ZooKeeper is a effort to develop and maintain an Open-source server which enables highly reliable distributed coor Dination.

ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed Synchronizatio N, and providing group services.

Click here to enter: ZooKeeper overview


Zookeeper is the base component in a distributed application environment where HDFS and yarn use zookeeper to configure a highly available (HA) system that can be automatically switched, based on zookeeper official documentation, using three virtual machines, Deploy the zookeeper cluster, using the virtual machine as mentioned earlier: Hadoop01, HADOOP02, hadoop03. The following is a detailed installation step.


1. On the hadoop01 machine, create a zookeeper user and join the Hadoop group (the section on creating a Hadoop group in this series of documents)

#以root用户登录hadoop01 Machine

[Email protected] hadoop]# useradd-m-G Hadoop Zookeeper


#首次启用, set the zookeeper user password
[Email protected] hadoop]# passwd zookeeper


2, download the latest Zookeeper release package: The official website recommended image Address

#zookeeper -3.4.8.tar.gz Copy to/home/zookeeper directory
[Email protected] ~]$ tar zxvf zookeeper-3.4.8.tar.gz
One more folder after decompression zookeeper-3.4.8


3, use Zookeeper user login, set environment variables

#在hadoop01机器上以zookeeper用户身份操作
[Email protected] hadoop]# Su-zookeeper

[Email protected] ~]$ Vi. bash_profile


Export PATH
#add start 20160628
Export zookeeper_home=/home/zookeeper/zookeeper-3.4.8
Export path= $PATH: $ZOOKEEPER _home/bin

#add End 20160628


#保存以上环境配置, after exiting VI, execute the following command when the environment variable is in effect

[[email protected] ~]$ source. bash_profile


4, set the zookeeper related parameters on the HADOOP01 machine

[Email protected] ~]$ CD zookeeper-3.4.8/conf/

#从样例复制一个配置文件模板

[email protected] zookeeper-3.4.8]$ CP zoo_sample.cfg zoo.cfg
#编辑配置文件
[email protected] conf]$ VI zoo.cfg


# The number of milliseconds of each tick

ticktime=2000
# The number of ticks that initial
# Synchronization phase can take
initlimit=10
# The number of ticks that can pass between
# Sending a request and getting an acknowledgement
Synclimit=5
# The directory where the snapshot is stored.
# do not use/tmp for storage,/tmp here are just

# example Sakes.

#modify Start 20160628

#dataDir =/tmp/zookeeper

Datadir=/home/zookeeper/zookeeper-3.4.8/zkdata

#modify End 20160628

# The port at which the clients would connect

clientport=2181
# The maximum number of the client connections.
# Increase this if you need to handle more clients
#maxClientCnxns =60
#
# Be sure to read the maintenance section of the
# Administrator Guide before turning on Autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in DataDir
#autopurge. snapretaincount=3
# Purge task interval in hours
# Set to ' 0 ' to disable Auto Purge feature

#autopurge. purgeinterval=1

#添加的配置信息

#modify Start 20160628

server.1=hadoop01:2888:3888
server.2=hadoop02:2888:3888

server.3=hadoop03:2888:3888

#modify End 20160628


5. Create working directory on HADOOP01 machine, set Zookeeper ID value (ID cannot be duplicated on different server)

#在 the hadoop01 machine to zookeeper the user to execute the following command

[Email protected] ~]$ cd/home/zookeeper/zookeeper-3.4.8

[Email protected] zookeeper-3.4.8]$ mkdir zkdata
[Email protected] zkdata]$ CD zkdata/
[[email protected] zkdata]$ echo ' 1 ' >myid


6. Perform related operations on hadoop02

#在HADOOP02On the machine, create the zookeeper user
[email protected] hadoop]# useradd-m-g Hadoop zookeeper


#在 the hadoop01 machine, perform the following actions

[Email protected] ~]$ Cd/home/zookeeper

[email protected] ~]$ scp-r zookeeper-3.4.8 hadoop02: $PWD


Switch zookeeper user identity on the #在hadoop02 Machine

[email protected] hadoop]# Su-zookeeper

[Email protected] ~]$ Vi. bash_profile


Export PATH
#add start 20160628
Export zookeeper_home=/home/zookeeper/zookeeper-3.4.8
Export path= $PATH: $ZOOKEEPER _home/bin

#add End 20160628


#保存以上环境配置, after exiting VI, execute the following command to make the environment variable effective

[[email protected] ~]$ source. bash_profile


7. Create working directory, set zookeeper ID value

#在hadoop02机器上 to zookeeper the user to execute the following command

[Email protected] ~]$ cd/home/zookeeper/zookeeper-3.4.8

[Email protected] zookeeper-3.4.8]$ mkdir zkdata
[Email protected] zkdata]$ CD zkdata/
[[email protected] zkdata]$ echo ' 2 ' >myid


8. Perform related operations on HADOOP03

#在HADOOP03On the machine, create the zookeeper user
[email protected] hadoop]# useradd-m-g Hadoop zookeeper


#在 the hadoop01 machine, perform the following actions

[Email protected] ~]$ Cd/home/zookeeper

[email protected] ~]$ scp-r zookeeper-3.4.8 hadoop03: $PWD


Switch zookeeper user identity on the #在hadoop03 Machine

[email protected] hadoop]# Su-zookeeper

[Email protected] ~]$ Vi. bash_profile


Export PATH
#add start 20160628
Export zookeeper_home=/home/zookeeper/zookeeper-3.4.8
Export path= $PATH: $ZOOKEEPER _home/bin

#add End 20160628


#保存以上环境配置, after exiting VI, execute the following command to make the environment variable effective

[[email protected] ~]$ source. bash_profile


9. Create working directory, set zookeeper ID value

#在 the hadoop03 machine to zookeeper the user to execute the following command

[Email protected] ~]$ cd/home/zookeeper/zookeeper-3.4.8

[Email protected] zookeeper-3.4.8]$ mkdir zkdata
[Email protected] zkdata]$ CD zkdata/
[[email protected] zkdata]$ echo ' 3 ' >myid


10. Start Zookeeper Cluster

run

[[email  protected] ~]$ zkserver.sh start
ZooKeeper JMX enabled by default
Using config:/home/zookeeper/ zookeeper-3.4.8/bin/. /conf/zoo.cfg
Starting Zookeeper ... STARTED


#在 hadoop03 machine run

[[email  protected] ~]$ zkserver.sh start
ZooKeeper JMX enabled by default
Using config:/home/zookeeper/ zookeeper-3.4.8/bin/. /conf/zoo.cfg
Starting Zookeeper ... STARTED


11. View Zookeeper Cluster status

[Email protected] ~]$ zkserver.sh status
ZooKeeper JMX enabled by default
Using config:/home/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg
Mode: follower

[Email protected] ~]$ zkserver.sh status
ZooKeeper JMX enabled by default
Using config:/home/zookeeper/zookeeper-3.4.8/bin/. /conf/zoo.cfg
Mode: leader


12. View the process of execution

[Email protected] ~]$ jps-l
5449 Org.apache.zookeeper.server.quorum.QuorumPeerMain


13. Close Zookeeper Cluster

Run on #在hadoop01 Machine

[[email protected] ~]$ zkserver.sh stop


Run on #在hadoop02 Machine

[[email protected] ~]$ zkserver.sh stop


Run on #在hadoop03 Machine

[[email protected] ~]$ zkserver.sh stop


14, demonstrated the open zookeeper cluster, as well as the process of killing leader server, automatically elect a new leader server situation.

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/84/2E/wKiom1eHoRGwlagDAAJViL9LkY0639.png-wh_500x0-wm_3 -wmp_4-s_3301827932.png "title=" Zookeeper.png "alt=" Wkiom1ehorgwlagdaajvil9lky0639.png-wh_50 "/>

This article from "Shen Jinqun" blog, declined reprint!

Big data: From Getting Started to XX (vi)

Related Article

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.