1 下载安装包

  wget https://mirrors.bfsu.edu.cn/apache/hadoop/common/hadoop-3.3.1/hadoop-3.3.1.tar.gz

2 解压,配置环境变量

tar -zxvf hadoop-3.3.1.tar.gz
vim /etc/profile
HADOOP_HOME=/APP/hadoop-3.3.1
PATH=$PATH:$JAVA_HOME/bin:$SPARK_HOME/bin:$HADOOP_HOME/bin
source /etc/profile

3 修改 hadoop-env.sh配置文件

 vi  /hadoop-3.3.1/etc/hadoop/hadoop-env.sh

加入如下配置

export JAVA_HOME=/APP/jdk1.8.0_141

4 修改 hdfs-site.xml 配置文件

 vi  /hadoop-3.3.1/etc/hadoop/hdfs-site.xml

加入如下内容,在标签内

<!-- 集群的namenode的位置  datanode能通过这个地址注册-->
<property>
<name>dfs.namenode.rpc-address</name>
<value>localhost:9000</value>
</property>

<!-- namenode存储元数据的位置 -->
<property>
<name>dfs.namenode.name.dir</name>
<value>/APP/hdpdata/name/</value>
</property>

<!-- datanode存储数据的位置 -->
<property>
<name>dfs.datanode.data.dir</name>
<value>/APP/hdpdata/data/</value>
</property>


<!--  WEB UI  -->
  <property>
     <name>dfs.namenode.http-address</name>
      <value>localhost:6002</value>
  </property>


</configuration>

5 初始化namedata

进入安装目录

/hadoop-3.3.1/bin

./hadoop  namenode  -format

查看有以下目录则初始化成功 “namenode存储元数据的位置”—> hdfs-site.xml 配置文件的位置

6 启动namenode和datanode

进入如下目录

/hadoop-3.3.1/sbin

启动

./hadoop-daemon.sh   start namenode
 ./hadoop-daemon.sh   start datanode  

3.3 配置 core-site.xml

 vi  /hadoop-3.3.1/etc/hadoop/core-site.xml

加入如下内容,在标签内

<name>fs.defaultFS</name>
  <value>hdfs://localhost:9000/</value>
  <description>The name of the default file system.  A URI whose
  scheme and authority determine the FileSystem implementation.  The
  uri's scheme determines the config property (fs.SCHEME.impl) naming
  the FileSystem implementation class.  The uri's authority is used to
  determine the host, port, etc. for a filesystem.</description>