sudo javac -classpath /usr/local/hadoop/share/hadoop/common/hadoop-common-2.6.0.jar:/usr/local/hadoop/share/hadoop/common/lib/hadoop-annotations-2.6.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.6.0.jar WordCount.java
我不明白我需要代替 写的命令javac -classpath
。
答案1
您还应该在命令中添加类文件的输出目标文件夹路径。
按着这些次序。
为类文件创建目标目录。例如,它被称为相交类。
mkdir intersect_classes
编译该程序。
sudo javac -classpath /usr/local/hadoop/share/hadoop/common/hadoop-common-2.6.0.jar:/usr/local/hadoop/share/hadoop/common/lib/hadoop-annotations-2.6.0.jar:/usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.6.0.jar -d intersect_classes WordCount.java
创建 jar 文件“intersect.jar”
jar -cvf intersect.jar -C intersect_classes/ .
将输入文件从本地源复制到 hadoop 文件系统
bin/hadoop dfs -put <path of input in localFileSystem>/inputfile <path of input in HDFS FileSystem>/inputfile
运行应用程序:
bin/hadoop jar intersect.jar Intersect <path of input in HDFS FileSystem>/inputFile <paht of output in HDFS FileSystem>/output
输出:
bin/hadoop dfs -cat <path of output in HDFS FileSystem>/output/*
根据 Reducer 的数量,输出文件夹可能包含多个输出文件。可以通过将“*”替换为输出文件夹中的文件名来查看确切文件的内容。
从 Hadoop 文件系统检索输出文件到本地目标:
bin/hadoop dfs -get <path of output in HDFS FileSystem>/output <path of output in HDFS FileSystem>/output