Hadoop单机安装与实现
时间: 2024-06-13 11:08:13 浏览: 23
以下是在Ubuntu上安装Hadoop单机模式并实现wordcount的步骤:
1.下载Hadoop压缩包并解压:
```shell
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-3.3.1/hadoop-3.3.1.tar.gz
tar -zxvf hadoop-3.3.1.tar.gz
```
2.配置环境变量:
```shell
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
```
3.修改Hadoop配置文件:
```shell
cd /usr/local/hadoop/etc/hadoop
cp mapred-site.xml.template mapred-site.xml
```
将mapred-site.xml中的以下内容修改为:
```xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
```
4.格式化Hadoop文件系统:
```shell
hdfs namenode -format
```
5.启动Hadoop:
```shell
start-all.sh
```
6.创建输入文件夹并上传文件:
```shell
hdfs dfs -mkdir /input
echo "Hello World" > test.txt
hdfs dfs -put test.txt /input
```
7.运行wordcount程序:
```shell
hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.1.jar wordcount /input /output
```
8.查看输出结果:
```shell
hdfs dfs -cat /output/*
```
输出结果为:
```
Hello 1
World 1
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)