Installing a highly available Hadoop ecosystem (ii) installation zookeeper

Source: Internet
Author: User
Tags hadoop ecosystem

2. Install the Zookeeper2.1. Decompression Program

※3 server to perform the respective

Tar-XF ~/Install/zookeeper-3.4.9.Tar. gz-c/opt/cloud/PackagesLN-s/opt/cloud/packages/zookeeper-3.4.9/opt/cloud/bin/ZookeeperLN-s/opt/cloud/packages/zookeeper-3.4.9/conf/opt/cloud/etc/Zookeepermkdir-p/opt/cloud/data/zookeeper/datmkdir-p/opt/cloud/data/zookeeper/Logdatmkdir-p/opt/cloud/logs/zookeeper
2.2. Modify the configuration file 2.2.1. Modify Zoo.cfg
mv /opt/cloud/etc/zookeeper/zoo_sample.cfg  /opt/cloud/etc/zookeeper/zoo.cfgVI / Opt/cloud/etc/zookeeper/zoo.cfg
# of milliseconds of each tickticktime= -# The number of ticks that the initial# synchronization phase can takeinitlimit=Ten# The number of ticks that can pass between# sending a request and getting an acknowledgementsynclimit=5# The directory where the snapshot is stored.# DoNot use/tmp forStorage,/tmp Here is just# example Sakes.datadir=/opt/cloud/data/zookeeper/Datdatalogdir=/opt/cloud/data/zookeeper/logdat[1]# the Port atwhichThe clients would connectclientport=2181# The maximum number of client connections.# increase thisifYou need to handle MoreClientsmaxclientcnxns= -# # is sure to read the maintenance sections of the# Administrator guide before turning on autopurge.## http://zookeeper.apache.org/doc/current/zookeeperadmin.html#sc_maintenance# # of snapshots to retaininchDatadirautopurge.snapretaincount=5[2]# Purge Task intervalinchhours# Set to"0"To disable Auto purge featureautopurge.purgeinterval=6# Server. A=B:c:dserver.1=HADOOP1:2888:3888[3]server.2=HADOOP2:2888:3888server.3=HADOOP3:2888:3888

2.2.2. Modifying the log configuration file
VI /opt/cloud/etc/zookeeper/log4j.properties

modifying configuration Items

Zookeeper.root.logger=INFO, DRFAzookeeper.log. dir=/opt/cloud/logs/zookeeper

Add Drfa Log Definition

Log4j.appender.drfa=Org.apache.log4j.DailyRollingFileAppenderlog4j.appender.DRFA.Append=trueLog4j.appender.DRFA.DatePattern='.'yyyy-mm-DDLog4j.appender.DRFA.File=${zookeeper.log.dir}/${zookeeper.log.file}log4j.appender.drfa.threshold=${zookeeper.log.threshold}log4j.appender.drfa.layout=Org.apache.log4j.PatternLayoutlog4j.appender.DRFA.layout.ConversionPattern=%d{iso8601} [Myid:%x{myid}]-%-5p [%t:%c{1}@%L]-%m%nlog4j.appender.DRFA.Encoding=utf-8#log4j. Appender.DRFA.MaxFileSize=20mb
2.2.3. Copying to 2 additional servers
SCP /opt/cloud/etc/zookeeper/zoo.cfg hadoop2:/opt/cloud/etc/zookeeperSCP /opt/cloud/ Etc/zookeeper/log4j.properties hadoop2:/opt/cloud/etc/ZookeeperSCP /opt/cloud/etc/zookeeper/ Zoo.cfg hadoop3:/opt/cloud/etc/ZookeeperSCP /opt/cloud/etc/zookeeper/log4j.properties hadoop3:/ Opt/cloud/etc/zookeeper
2.3. Generate myID

Create a myID file in the DataDir directory, and then in the myID file, according to the value of a in Server.a of the Zoo.cfg file, fill in the corresponding value in the file on the different machine.

SSH ' Echo 1 >/opt/cloud/data/zookeeper/dat/myid ' SSH ' Echo 2 >/opt/cloud/data/zookeeper/dat/myid ' SSH ' Echo 3 >/opt/cloud/data/zookeeper/dat/myid '
2.4. Setting Environment variables

VI ~/.BASHRC

Increase

Export zoo_home=/opt/cloud/bin/zookeeperexport zoocfgdir=${zoo_home}/confexport zoo_log_dir =/opt/cloud/logs/zookeeperexport PATH= $ZOO _home/bin: $PATH

Immediate effect

SOURCE ~/.BASHRC

Replicate to two other servers

SCP ~/.BASHRC hadoop2:/home/hadoopSCP ~/.BASHRC Hadoop3:/home/hadoop
2.5. Manual execution

1. Start

Zkserver. SH start

2. Enter the JPS command to view the process

Quorumpeermainjps

Among them, Quorumpeermain is the zookeeper process, starting normal.

3. Stop Zookeeper Process

Zkserver. SH stop

4. Start Zookeeper cluster

' zkserver.sh Start '************************* cloud *************************---------hadoop1---------/opt/cloud/ bin/zookeeper/bin/. /conf/zoo.cfgstarting Zookeeper ... STARTED---------hadoop2---------/opt/cloud/bin/zookeeper/bin/. /conf/zoo.cfgstarting Zookeeper ... STARTED---------hadoop3---------/opt/cloud/bin/zookeeper/bin/. /conf/zoo.cfgstarting Zookeeper ... STARTED

5. View Zookeeper cluster status

' zkserver.sh Status '************************* cloud *************************---------hadoop1---------/opt/cloud/ bin/zookeeper/bin/. /conf/zoo.cfgMode:follower---------hadoop2---------/opt/cloud/bin/zookeeper/bin/. /conf/zoo.cfgMode:follower---------hadoop3---------/opt/cloud/bin/zookeeper/bin/. /conf/Zoo.cfgMode:leader

6. Start client Script

Zkcli. SH ls /zookeeperls /zookeeper/quota
2.6. Automatically run when system starts
VI /opt/cloud/bin/zookeeper/bin/zkserver. SH
" $JAVA " " -dzookeeper.log.dir=${zoo_log_dir} " " -dzookeeper.root.logger=${zoo_log4j_prop} "  "$JAVA""-dlog4j.configuration=file:${zoocfgdir}/ Log4j.properties" \

Replicate to two other servers

SCP /opt/cloud/bin/zookeeper/bin/zkenv. sh hadoop2:/opt/cloud/bin/zookeeper/bin/SCP /opt/cloud/bin/zookeeper/bin/zkserver. sh hadoop2:/opt/cloud/bin/zookeeper/bin/SCP /opt/cloud/bin/zookeeper/bin/zkenv. sh hadoop3:/opt/cloud/bin/zookeeper/bin/SCP /opt/cloud/bin/zookeeper/bin/zkserver. SH hadoop3:/opt/cloud/bin/zookeeper/bin/

Vi/etc/systemd/system/zookeeper.service

[Unit]description=Zookeeper Serviceafter=Network.target[service]user=Hadoopgroup=Hadooptype=Forking Environment= zoo_home=/opt/cloud/bin/zookeeperenvironment= zoocfgdir=/opt/cloud/bin/zookeeper/confenvironment= zoo_log_dir=/opt/cloud/logs/Zookeeperexecstart=/usr/bin/SH-C'/opt/cloud/bin/zookeeper/bin/zkserver.sh Start'Execstop=/usr/bin/SH-C'/opt/cloud/bin/zookeeper/bin/zkserver.sh Stop'[Install]wantedby=multi-user.target

Replicate to two other servers

SCP /etc/systemd/system/zookeeper.service hadoop2:/etc/systemd/system/SCP /etc/systemd/system/ Zookeeper.service hadoop3:/etc/systemd/system/

Reload configuration information: Systemctl daemon-reload

Start Zookeeper:systemctl Start Zookeeper

Stop Zookeeper:systemctl Stop Zookeeper

View process status and logs (important): Systemctl status Zookeeper

Boot from: Systemctl Enable zookeeper

Off self-booting: Systemctl Disable zookeeper

Start Service set to start automatically

Systemctl daemon-reloadsystemctl start zookeepersystemctl status Zookeepersystemctl enable Zookeeper
2.7. Uninstall

Root User Action

    • Stop and uninstall the Zookeeper service
   systemctl Stop zookeeper   systemctl disable zookeeper   rm /etc/systemd/system/ Zookeeper.service-f
    • Resiliency environment variables

VI ~/.BASHRC

Delete Zookeeper related rows

    • Delete other files
   RM /opt/cloud/bin/zookeeper/-RF   RM /opt/cloud/data/zookeeper/-RF    RM /opt/cloud/logs/zookeeper/-RF   RM /opt/cloud/packages/zookeeper-3.4 . 9/-RF

[1] #如果有高速设备, the Datelogdir can be set on high-speed equipment to significantly improve efficiency

[2] Setting the data timing cleanup mechanism

[3] # server. A=B:C:D:

# A is a number that indicates this is the first server

# B is the IP address of this server;

# C represents the port where the server exchanges information with the leader server in the cluster;

# D indicates the port used by the server to communicate with each other when performing an election.

Installing a highly available Hadoop ecosystem (ii) installation zookeeper

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.