hadoop cluster building on mac

1. Environmental Instructions

Environment & SoftwareEdition
Operating System & MacOs11.2.1
Virtual Machine & VMware Fusion12.1
Server & CentOS7.8

2. Virtual Machine Preparation

1. Configure static ip

1.1 Virtual Machine Network Settings (NAT)

VMWARE Fusion sets the virtual machine network adapter link mode to "Share with my Mac"

1.2 View local network configuration

  1. View the local gateway address and subnet mask:
cat /Library/Preferences/VMware\ Fusion/vmnet8/nat.conf

2. View the range of static ip addresses the virtual machine allows to select

cat /Library/Preferences/VMware\ Fusion/vmnet8/dhcpd.conf

3. View mac native dns: Settings - Network - Advanced

1.3 Modify virtual machine configuration

Configuring static ip only requires this step, all of which is to see what information the current machine should configure

  1. Log on to the virtual machine (you can use mac command line ssh) username@ip )
  2. Modify the configuration file, noting that the file name begins with ifcfg-en
vi /etc/sysconfig/network-scripts/ifcfg-ens33


1.4 Verify static ip

Restart Network Service Effective

service network restart

ping extranet

ping baidu.com

2. Configure hostname

2.1 Set Host Name

hostnamectl set-hostname linux01

2.2 View hostname


2.2 Cluster Host Name Settings

vi /etc/hosts

3. Close the firewall

systemctl stop iptables 
systemctl stop firewalld
systemctl disable firewalld.service 

4. Implement ssh Secret-Free Interchange

Id_to be generated per machine Rsa. Pub append to the same authorized_keys, and then authorized_keys sent to other remote hosts

4.1 Generate public and private keys for each machine, and use default values for line-break returns

ssh-keygen -t rsa

4.2 Append each public key to the same server


4.3 Authorized_to be generated on machines with public keys Keys file sent to other hosts

scp -r ~/.ssh/authorized_keys
scp -r ~/.ssh/authorized_keys

4.4 Verify ssh Interchange

ssh linux01
ssh linux02
ssh linux03

Problems you may encounter during virtual machine preparation:

  1. The ifconfig command is not available: yum-y install net-tools
  2. The Yum command failed to execute: execute the nmtui command, then select Edit a connection - select ens33 - Automatically connect tick, exit retry the yum command

3. Setting up a hadoop cluster

1. jdk and hadoop software installation

1.1 Specify the software installation folder

Software Installation Package Storage Directory
mkdir -p /opt/dayu/software
 Software Installation Directory
mkdir -p /opt/dayu/servers

1.2 Upload installation package

scp -r jdk-8u231-linux-x64.tar.gz root@
scp -r hadoop-2.9.2.tar.gz  root@

1.3 Unzip the software to the specified installation directory

tar -zxvf jdk-8u231-linux-x64.tar.gz -C /opt/dayu/servers/
tar -zxvf hadoop-2.9.2.tar.gz -C /opt/dayu/servers/

1.4 Append environment variables

vi /etc/profile
export JAVA_HOME=/opt/dayu/servers/jdk1.8.0_231
export PATH=$PATH:$JAVA_HOME/bin
export HADOOP_HOME=/opt/dayu/servers/hadoop-2.9.2

1.5 Verify successful software installation

source /etc/profile
java -version
hadoop version

2. hadoop cluster configuration

Hadoop Cluster Configuration= HDFS Cluster Configuration + MapReduce Cluster Configuration + Yarn Cluster Configuration
The folder where the profile is located:

To avoid confusion, modify the users and user groups that the Hadoop installation directory belongs to
chown -R root:root /opt/dayu/servers/hadoop-2.9.2

2.1 HDFS cluster configuration

  1. Clearly configure the JDK path to HDFS (modify hadoop-env.sh)
export JAVA_HOME=/opt/dayu/servers/jdk1.8.0_231
  1. Specify NameNode node and data store directory (modify core-site.xml)
  <!-- Appoint Hadoop Storage directory where files are generated at runtime -->
  1. Specify the SecondaryNameNode node (modify hdfs-site.xml)
  <!-- Appoint Hadoop Secondary Name Node Host Configuration -->
  <!--Number of copies -->
  1. Specify DataNode slave nodes (modify the slaves file, one line for each node configuration information)

2.2 MapReduce Cluster Configuration

  1. Clearly configure the JDK path to MapReduce (modify mapred-env.sh)
export JAVA_HOME=/opt/dayu/servers/jdk1.8.0_231
  1. Specify the MapReduce Computing Framework to run the Yarn Resource Scheduling Framework (modify mapred-site.xml)
// Change profile template name to formal profile name first
mv mapred-site.xml.template mapred-site.xml
  <!-- Appoint MR Run on Yarn upper -->

2.3 Yarn Cluster Configuration

  1. Clearly configure the JDK path to Yarn (modify yarn-env.sh)
export JAVA_HOME=/opt/dayu/servers/jdk1.8.0_231
  1. Specify the computer section where the ResourceManager master node is located (modify yarn-site.xml)
  <!-- Appoint YARN Of ResourceManager Address -->
  <!-- Reducer How to get data -->
  1. Specify the NodeManager node (no configuration required, determined by the contents of the slaves file)

3. Distribution Configuration on Machine Nodes (rsync)

rsync is mainly used for backup and mirroring. It has the advantages of fast speed, avoiding duplication of the same content and supporting symbolic links.
Difference between rsync and scp: Files copied with rsync are faster than scp, rsync only updates the difference files. SCP is all text
Copy them all over.

3.1 Install rsync

yum install -y rsync

3.2 Writing shell scripts

# Create script
touch rsync-script
# Modify script has execute permission
chmod 777 rsync-script
# This command allows you to synchronize configuration files after scripting
rsync-script /opt/dayu/servers/hadoop-2.9.2

#1 Get the number of command input parameters, if the number is 0, exit the command directly
if((paramnum==0)); then
echo no params;

#2 Get the file name from the incoming parameter
file_name=`basename $p1`
echo fname=$file_name

#3 Get absolute path of input parameter
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir

#4 Get the user name

#5 Loop execution rsync
for((host=1; host<4; host++)); do
echo ------------------- linux0$host --------------
rsync -rvl $pdir/$file_name $user@linux0$host:$pdir

3. hadoop cluster startup

Initialize if not started

hadoop namenode -format

1. Clustering


2. View cluster startup status


3. web side view Hdfs interface

Keywords: Hadoop

Added by beyers on Thu, 10 Feb 2022 02:12:24 +0200