Introduction to Hadoop deployment


Hadoop overview and deployment

reference resources:…

1. Hadoop overview

  • What is Hadoop?

Hadoop is a distributed system infrastructure developed by Apache foundation, which is used to solve the problems of massive data storage and analysis.

  • Advantages of Hadoop

    • High reliability: the bottom layer of Hadoop data storage adopts multiple copies
    • High expansion: cluster deployment can easily expand nodes
    • Efficiency: Hadoop works in parallel to speed up task processing
    • High error tolerance: can automatically reallocate failed tasks

2. Hadoop composition

  • The 2. X and 3. X versions are as follows:

    • MapReduce: computing
    • Yarn: resource scheduling
    • HDFS: data storage
    • Common: auxiliary tool

Note: in version 1. X, yarn and mapredcuer are not responsible for computing and resource scheduling

3. Deployment planning

  • Three virtual machines
IP host name operating system to configure node CentOS 7.5 1 core / 4G memory / 50g hard disk NameNode、DataNode、NodeManager CentOS 7.5 1 core / 4G memory / 50g hard disk ResourceManager、DataNode、NodeManager CentOS 7.5 1 core / 4G memory / 50g hard disk SecondaryNameNode、DataNode、NodeManager

4. Cluster deployment

4.1 system update and SSH free configuration

  • Update and upgrade
yum install  -y epel-release
yum update
  • Configure SSH password free login
[[email protected] ~]$ ssh-keygen -t rsa
//... enter continuously to generate the private key ID_ RSA and ID_
//My user is v2admin, and all subsequent operations are based on this user
[[email protected] ~]$ ssh-copy-id hadoop10
[[email protected] ~]$ ssh-copy-id hadoop11
[[email protected] ~]$ ssh-copy-id hadoop12
//Hadoop 11 and Hadoop 12 do the same
  • Upload JDK and Hadoop packages to the / home / v2admin directory of three virtual machines
//My own operating system is Ubuntu 18.04, which directly uses SCP to upload.
//If you use Windows system, you can install lrzsz or upload it to the virtual machine by FTP
scp jdk-8u212-linux-x64.tar.gz hadoop-3.1.3.tar.gz  [email protected]:/home/v2admin

scp jdk-8u212-linux-x64.tar.gz hadoop-3.1.3.tar.gz  [email protected]:/home/v2admin

scp jdk-8u212-linux-x64.tar.gz hadoop-3.1.3.tar.gz  [email protected]:/home/v2admin

4.2 installing JDK

[[email protected] ~]$tar zxvf jdk-8u212-linux-x64.tar.gz
[[email protected] ~]$sudo mv jdk1.8.0_212/ /usr/local/jdk8

4.2 installing Hadoop

[[email protected] ~]$sudo  tar zxvf hadoop-3.1.3.tar.gz -C /opt
[ [email protected]  ~]$ sudo chown -R v2 admin:v2admin /opt/hadoop-3.1.3   //Modify the user and group to the current user

4.3 configure JDK and Hadoop environment variables

[ [email protected]  ~]$sudo VIM / etc / profile // add last face
# set jdk hadoop env
export JAVA_HOME=/usr/local/jdk8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export HADOOP_HOME=/opt/hadoop-3.1.3
export PATH=${PATH}:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin

[[email protected] ~]$source /etc/profile
[ [email protected]  ~]$Java - Version // verify JDK
java version "1.8.0_212"
Java(TM) SE Runtime Environment (build 1.8.0_212-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode)

[ [email protected]  ~]$Hadoop version // verify Hadoop
Hadoop 3.1.3
Source code repository -r ba631c436b806728f8ec2f54ab1e289526c90579
Compiled by ztang on 2019-09-12T02:47Z
Compiled with protoc 2.5.0
From source with checksum ec785077c385118ac91aadde5ec9799
This command was run using /opt/module/hadoop-3.1.3/share/hadoop/common/hadoop-common-3.1.3.jar

4.4 script for distributing files

Because the configuration files of the three virtual machines are the same, if there is no script, you need to configure them one by one, which is very cumbersome
Script file name
Give the execution permission and put it in the bin directory, which can be called directly like other shell commands

if [ $# -lt 1 ]
        echo Not Enough Arguement!

for host in hadoop10 hadoop11 hadoop12
        echo ============= $host ============
        for file in [email protected]
                if [ -e $file ]
                        pdir=$(cd -P $(dirname $file);pwd)
                        fname=$(basename $file)
                        ssh $host "mkdir -p $pdir"
                        rsync -av $pdir/$fname $host:$pdir
                        echo $file does not exists!

4.5 cluster configuration

  • Java of Hadoop under 4.5.1 configuration_ HOME
[[email protected] ~]$ cd /opt/hadoop-3.1.3/etc/hadoop
[[email protected] ~]$ vim
//Modify Java_ Home content
export JAVA_HOME=/usr/local/jdk8

[ [email protected]  ~]$xrsync hadoop-   //Update the configuration files of the other two hosts synchronously
  • 4.5.2 core configuration


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
   <! -- address of namenode -- >




 <! -- storage directory of Hadoop data -- >












<! -- designated user -- >



  • 4.5.3 HDFS configuration


 <! -- storage directory of namenode data -- >




<! -- datanode data storage directory -- >




<! -- storage directory of 2n data -- >








<! -- NN's Web access address -- >




  • 4.5.4 yarn configuration



<!-- Site specific YARN configuration properties -->
























  • 4.5.5 MapReduce configuration







<! -- historical server address -- >





<! -- web address of history server -- >





  • 4.5.6 use script to distribute good configuration files on cluster

4.6 script to start cluster

To start a cluster, you need to perform relevant startup operations on each server. In order to start the cluster and view the startup information, write a startup script

if [ $# -lt 1 ]
  echo "Not enough arguments Input !!!"

case $1 in
#Start up
    echo "==========start hdfs============="
    ssh hadoop10 /opt/module/hadoop-3.1.3/sbin/
    echo "==========start historyServer============"
    ssh hadoop10 /opt/module/hadoop-3.1.3/bin/mapred --daemon start historyserver
    echo "==========start yarn============"
    ssh hadoop11 /opt/module/hadoop-3.1.3/sbin/

        echo "==========stop hdfs============="
        ssh hadoop10 /opt/module/hadoop-3.1.3/sbin/
        echo "==========stop yarn============"
        ssh hadoop11 /opt/module/hadoop-3.1.3/sbin/
    echo "==========stop historyserver===="
    ssh hadoop10 /opt/module/hadoop-3.1.3/bin/mapred --daemon stop historyserver

#View startup information
    for i in hadoop10 hadoop11 hadoop12
        echo "==============$i jps================"
        ssh $i /usr/local/jdk8/bin/jps
 echo "Input Args Error!!!"

Also put it in the / bin directory for direct call

4.7 start cluster and view startup information

[ [email protected]  ~]$  Start // start
==========start hdfs=============
Starting namenodes on [hadoop10]
Starting datanodes
Starting secondary namenodes [hadoop12]
==========start historyServer============
==========start yarn============
Starting resourcemanager
Starting nodemanagers
[ [email protected]  ~]$  JPS // view startup information
==============hadoop10 jps================
1831 NameNode
2504 Jps
2265 JobHistoryServer
1980 DataNode
2382 NodeManager
==============hadoop11 jps================
1635 DataNode
1814 ResourceManager
2297 Jps
1949 NodeManager
==============hadoop12 jps================
1795 NodeManager
1590 DataNode
1927 Jps
1706 SecondaryNameNode

4.8 possible problems

After the installation and deployment is completed, there may be some problems when startingNoClassDefFoundError: javax/activation/DataSource
I didn’t use 2. X before, but I plan to install 3. X this time. The reason for this problem is that there is no jar package in yarn’s lib

cd /opt/hadoop-3.1.3/share/hadoop/yarn/lib