Hadoop MapReduce 单词统计实验:拓展与命令详解

实验内容:

在 Hadoop MapReduce 的单词统计实验中,将以下内容写入 myword.txt 文件:

'jim' 1 28
'kate' 0 26
'tom' 1
'lily' 0 29 22
'Tom' 1 30
'Jnoe' 2
'Min' 2 31 4
'Hala' 1 27
'Hua' 0
'Teey' 1 28 2

命令操作:

在终端中,键入以下命令以运行 Map Reduce 程序进行单词统计:

hadoop jar <path_to_jar_file> <main_class> <input_file_path> <output_directory_path>

其中,<path_to_jar_file> 是包含 Map Reduce 程序的 JAR 文件的路径,<main_class> 是主类名,<input_file_path> 是输入文件的路径,<output_directory_path> 是输出目录的路径。

假设我们的 JAR 文件名为 wordcount.jar,主类名为 WordCount,输入文件 myword.txt 位于 Hadoop 分布式文件系统的 /input 目录下,输出结果将保存在 /output 目录下。则键入的命令如下:

hadoop jar wordcount.jar WordCount /input/myword.txt /output

执行以上命令后,程序将启动 Map Reduce 任务并进行单词统计。执行完成后,可以使用以下命令查看输出结果:

hadoop fs -cat /output/part-r-00000

以上命令将输出结果显示在终端上。


原文地址: https://www.cveoy.top/t/topic/o7cU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录