[Hadoop article 02] Hadoop completely distributed environment to build

Posted Jun 28, 20203 min read

Better than others, not noble, the real noble should be better than the past

Hadoop completely distributed environment

Write distribution file script

Application scenarios are as follows:For example, there are three hosts master1, slave1, slave2

If the resume is completely distributed in the cluster, you need to copy the file from master1 to the slave

Then you can use the rsync command to distribute a single file, or you can use the following script to distribute folders or files


#1 Get the number of input parameters, if there are no parameters, just exit
# $# represents the number of command line parameters
if((pcount==0)); then
echo no args;

#2 Get the file name
# $1 means to get the first parameter on the command line
fname=`basename $p1`
echo fname=$fname

#3 Get the upper directory to the absolute path
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir

#4 Get the current user name

#5 rsync command can distribute files to the specified host
# Here slave is the name of the slave
for((host=1; host<3; host++))
        echo ------------------- slave$host --------------
        rsync -rvl $pdir/$fname $user@slave$host:$pdir

Cluster planning

hadoop102 hadoop103 hadoop104
HDFS NameNodeDataNode DataNode SecondaryNameNode
YARN NodeManager ResourceManager

Configure the cluster

Configuration files are under hadoop2.7.2/etc/hadoop

Configure core-site.xml

<!-- Specify the address of NameNode in HDFS -->

<!-- Specify the storage directory of files generated when Hadoop runs -->

Configure hadoop-env.sh

export JAVA_HOME=/opt/module/jdk1.8.0_144

Configure hdfs-site.xml

<!-- Specify the number of copies -->

<!-- Specify SecondaryNamenode host configuration -->

Configure yarn-env.sh

export JAVA_HOME=/opt/module/jdk1.8.0_144

Configure yarn-site.xml

<!-- How reducer gets data -->

<!-- Specify the address of YARN's ResourceManager -->

Configure mapred-env.sh

export JAVA_HOME=/opt/module/jdk1.8.0_144

Configure mapred-site.xml

[Need to copy mapred-site.xml.template and rename it]

<!-- Specify mr to run on yarn -->

Distribute the configuration to the cluster

# xsync is the distribution script just written
xsync /opt/module/hadoop-2.7.2/

Cluster format

# This part must be reported without errors, otherwise it will be repeated, it must be executed in the root directory of hadoop
hadoop namenode -format

Cluster startup test

On the host hadooop102 in the sbin directory, run start-dfs.sh to start HDFS
On the host hadooop103 in the sbin directory, run start-yarn.sh to start yarn
Then use jps to view the process


Relevant information


This article is supported GitHub: https://github.com/zhutiansam...

This article supporting public number:FocusBigData

Reply [Big Data Interview][Big Data Interview Experience][Big Data Learning Roadmap]There will be surprises