五个节点:2个Master+3个Slave
CentOS-8.4.2105-x86_64-dvd1.iso
hadoop-3.3.1.tar.gz
jdk-8u221-linux-x64.tar.gz
apache-zookeeper-3.7.0-bin.tar.gz
新建虚拟机,对centos进行配置
基础配置
切换到root用户,才能进行配置
su -l root
1.配置ip
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
2.设置DNS域名解析的配置文件
vi /etc/resolv.conf
3.配置hosts文件
vi /etc/hosts
添加
192.168.64.101 Master001
192.168.64.102 Master002
192.168.64.133 Slave1
192.168.64.144 Slave2
192.168.64.155 Slave3
4.重启网络服务
nmcli connection reload
nmcli connection up ens33
nmcli d connect ens33
5.修改主机名
[root@localhost ~]# vi /etc/sysconfig/network
创建hadoop用户(!!!!!此步骤可做可不做)
adduser hadoop
passwd hadoop
如果没创建hadoop用户,自己在现有的用户下进行下面步骤即可
在hadoop用户下创建software文件夹
su -l root
[root@Master1 hadoop]# mkdir software
解压(需在root用户下)
tar -zxf 文件
补充:
切换为root用户
su -l root
解压并配置jdk
命令:
vi /etc/profile
配置内容:
export JAVA_HOME=/home/hadoop/software/jdk1.8.0_221
export PATH=$PATH:$JAVA_HOME/bin
使命令生效:
source /etc/profile
查看是否成功:
java -version
解压并配置hadoop
解压:
tar -zxf hadoop-3.3.1.tar.gz
命令:
vi /etc/profile
配置内容:
#hadoop
export HADOOP_HOME=/home/hadoop/software/hadoop-3.3.1
#hadoop位置根据放置的位置决定
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH
使命令生效:
source /etc/profile
查看是否成功:
hadoop
集群分布式搭建
进入这个目录
cd /home/hadoop/software/hadoop-3.3.1/etc/hadoop
切换为root用户
su -l root
配置core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://mycluster</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/software/hadoop-3.3.1/tmp</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>Slave1:2181,Slave2:2181,Slave3:2181</value>
</property>
</configuration>
配置hadoop-env.sh
修改
export</