2011年3月21日 星期一

How to compile MapReduce file and run it

以下以hadoop-0.20.2為例
Compile:
javac -classpath /{yourPathToHadoop}/hadoop-0.20.2-core.jar yourfile -d {outputDir}
For example:
javac -classpath /usr/local/hadoop/hadoop-0.20.2-core.jar myWordCount.java -d bin/

把bin內的檔案包成 jar檔
jar -cvf {OutputJarName} -C bin/ .
For example:
jar -cvf output.jar -C bin/ .

放到 hadoop上跑
hadoop jar {yourJarName} {MainClassName}
For example:
hadoop jar output.jar myWordCount input output
P.S. 後面的input output為myWordCount程式的參數

沒有留言:

張貼留言