大数据全系列 教程
1869个小节阅读:465.3k
目录
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
启动hadoop集群,在node1上执行:startha.sh,查看四个节点上java进程是否正常
浏览器器中测试
创建输入路径
xxxxxxxxxx
[root@node1 ~]# hdfs dfs -mkdir -p /weather/input/
创建数据文件,并将数据源中的数据拷贝到该文件中
xxxxxxxxxx
[root@node1 ~]# vim data.txt
2019-10-01 14:21:02 37c
2019-10-01 19:21:02 38c
2019-10-02 14:01:02 36c
2019-10-03 14:01:02 35c
2020-01-01 11:21:02 32c
2020-10-01 12:21:02 37c
2018-12-01 12:21:02 23c
2020-10-02 12:21:02 41c
2020-10-03 12:21:02 27c
2018-07-01 12:21:02 45c
2018-07-02 12:21:02 46c
2018-07-03 12:21:03 47c
将data.txt文件提交hdfs文件系统的/weather/input目录
xxxxxxxxxx
[root@node1 ~]# hdfs dfs -put data.txt /weather/input
[root@node1 ~]# hdfs dfs -ls /weather/input
Found 1 items
-rw-r--r-- 3 root supergroup 288 2021-11-04 11:55 /weather/input/data.txt
在IDEA中运行WeatherDriver类
xxxxxxxxxx
Usage:yarn jar myweather.jar com.itbaizhan.WeatherDriver <inputPath> <outputPath>
说明没有指定输入和输出路径,所以接下来设置输入输出路径。
在IDEA中设置输入输出路径
点击Appliy,然后点击OK
再次在IDEA运行程序
检查执行后的结果文件是否生成
通过命令查看这四个文件中的内容:
xxxxxxxxxx
[root@node1 ~]# hdfs dfs -cat /weather/output/part-r-00002
2019-10-01 19:21:02 38c
2019-10-02 14:01:02 36c
2020-10-02 12:21:02 41c
2020-10-01 12:21:02 37c