一、安装Java
1. 下载Java
进入下载页面Java Archive Downloads - Java SE 8
Java SE Development Kit 8u191中
选择适合操作系统的下载文件
在安装好的路径下,将Java目录复制到C:\根目录下,形成C:\Java\jdk1.8.0_191目录结构
2. 设置环境变量
二、安装Hadoop
1. 下载hadoop-3.3.0
进入下载页面
https://archive.apache.org/dist/hadoop/common/hadoop-3.3.0/
选择hadoop-3.3.0.tar.gz下载
https://archive.apache.org/dist/hadoop/common/hadoop-3.3.0/hadoop-3.3.0.tar.gz
解压到C:\hadoop-3.3.0目录,形成C:\hadoop-3.3.0\bin这种目录层次
2. 下载winutils替换hadoop-3.3.0\bin目录
下载winutils
https://github.com/s911415/apache-hadoop-3.1.0-winutils
将其中bin目录替换到C:\hadoop-3.3.0\下的bin目录
3. 设置环境变量
4. 修改配置
C:\hadoop-3.3.0\etc\hadoop目录下有4个配置文件
C:\hadoop-3.3.0\etc\hadoop\core-site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9820</value>
</property>
</configuration>
C:\hadoop-3.3.0\etc\hadoop\hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:///C:/hadoop-3.3.0/data/dfs/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:///C:/hadoop-3.3.0/data/dfs/datanode</value>
</property>
</configuration>
C:\hadoop-3.3.0\etc\hadoop\mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
<description>MapReduce framework name</description>
</property>
</configuration>
C:\hadoop-3.3.0\etc\hadoop\yarn-site.xml
<configuration>
<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
<description>Yarn Node Manager Aux Service</description>
</property>
</configuration>
5. 格式化目录
cd C:\hadoop-3.3.0\bin
hdfs namenode -format
注意:-format中开头的短横容易写成全角下的短横,这样会导致错误,一定要用半角短横
6. 验证服务
C:\hadoop-3.3.0\sbin> jps
17504 NameNode
17584 Jps
20944 NodeManager
3852 DataNode
4572 ResourceManager
PS C:\hadoop-3.3.0\sbin>
7. 解决启动问题
进入C:\hadoop-3.3.0\sbin
执行start-dfs.cmd文件
cd C:\hadoop-3.3.0\sbin
start-dfs.cmd
执行start-yarn.cmd文件
cd C:\hadoop-3.3.0\sbin
start-yarn.cmd
可能问题:
如果出现不错:
java.lang.NoClassDefFoundError: org/apache/hadoop/yarn/server/timelineservice/collector/TimelineColl
可以复制
C:\hadoop-3.3.0\share\hadoop\yarn\timelineservice
到
C:\hadoop-3.3.0\share\hadoop\yarn
8. Hadoop的WebUI工具
- Name node web page: http://localhost:9870/dfshealth.html
- Data node web page: http://localhost:9864/datanode.html
- Yarn web page: http://localhost:8088/cluster
三、参考文章
https://brain-mentors.com/hadoopinstallation/
https://towardsdatascience.com/installing-hadoop-3-2-1-single-node-cluster-on-windows-10-ac258dd48aef