To jazz:
透過這個網頁,我的問題已經順利解決
http://hadoopintouch.blogspot.tw/2012/04/write-your-first-program-in-hadoop-in-c.htmlStep 1:
compile the program using g++
following is the command to compile
代碼:
g++ -I/opt/hadoop/c++/Linux-amd64-64/include -c wordcount.cpp
g++ wordcount.o -o wordcount -L/opt/hadoop/c++/Linux-amd64-64/lib -lnsl -lpthread -lhadooppipes -lhadooputils
it will create WordCount binary into your current folder.
Step 2:
Now pur this binary into hadoop hdfs by using following command:
代碼:
bin/hadoop fs -mkdir /user/test
bin/hadoop fs -put WordCount /user/test/
Step 3:
Now make a input file for your test.
use the following command
代碼:
vim input.txt
press i
write few lines
press esc then press wq.
Step 4:
keep your input inside the hadoop by using the following command:
代碼:
bin/hadoop fs -put input.txt /user/test/
Step 5:
Now run your program using following command:
代碼:
bin/hadoop pipes -D hadoop.pipes.java.recordreader=true -D hadoop.pipes.java.recordwriter=true -program /user/test/WordCount -input /user/test/input.txt -output /user/test/output
Hopefully it will get run now you can see your output in the output directory which we have given at the time of run /user/test/output.
to see the output type following command:
代碼:
bin/hadoop fs -text /user/test/output/part-00000