hadoop的streaming以及libhdfs试用

由于实验室的一个活儿需要把以前单机版的一个搜索核心集成到hadoop上来,该核心又是用c++写的,所以今天试用了streaming以及libhdfs。网上相关的资料也不是太多,写下来希望对大家有所帮助。

     编译libhdfs:ant compile-c++-libhdfs -Dislibhdfs=true。然后就会有libhdfs.so。

然后写好自己的c++程序,编译记得要-L. lhdfs -L. -ljvm。

error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or directory 这个问题看这里http://www.cnblogs.com/amboyna/archive/2008/02/06/1065322.html

将mapper和reducer程序都写好了并编译好了之后,就该提交到hadoop上了。 

运行该作业遇到了这个问题Environment variable CLASSPATH not set!

java.lang.RuntimeException: PipeMapRed.waitOutputThreads(): subprocess failed with code 255 

因此设定了一把classpath。  hadoop jar /hadoop/hadoop-0.20.2/contrib/streaming/hadoop-0.20.2-streaming.jar -input ** -output ** -mapper ** -reducer ** -jobconf ** -cmdenv CLASSPATH=$CLASSPATH

然后就OK。

利用libhdfs可以顺利的控制hdfs的文件,搞定。 

posted on 2011-02-21 20:36  Shall  阅读(1855)  评论(3)    收藏  举报

导航