I'm trying to get map-reduce functionality with python using mongo-hadoop. Hadoop is working, hadoop streaming is working with python and the mongo-hadoop adaptor is working. However, the mongo-hadoop streaming examples with python aren't working. When trying to run the example in streaming/examples/treasury I get the following error:
$user@host: ~/git/mongo-hadoop/streaming$ hadoop jar target/mongo-hadoop-streaming-assembly-1.0.1.jar -mapper examples/treasury/mapper.py -reducer examples/treasury/reducer.py -inputformat com.mongodb.hadoop.mapred.MongoInputFormat -outputformat com.mongodb.hadoop.mapred.MongoOutputFormat -inputURI mongodb://127.0.0.1/mongo_hadoop.yield_historical.in -outputURI mongodb://127.0.0.1/mongo_hadoop.yield_historical.streaming.out
13/04/09 11:54:34 INFO streaming.MongoStreamJob: Running
13/04/09 11:54:34 INFO streaming.MongoStreamJob: Init
13/04/09 11:54:34 INFO streaming.MongoStreamJob: Process Args
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Setup Options'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: PreProcess Args
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Parse Options
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: '-mapper'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: 'examples/treasury/mapper.py'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: '-reducer'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: 'examples/treasury/reducer.py'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: '-inputformat'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: 'com.mongodb.hadoop.mapred.MongoInputFormat'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: '-outputformat'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: 'com.mongodb.hadoop.mapred.MongoOutputFormat'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: '-inputURI'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: 'mongodb://127.0.0.1/mongo_hadoop.yield_historical.in'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: '-outputURI'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Arg: 'mongodb://127.0.0.1/mongo_hadoop.yield_historical.streaming.out'
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Add InputSpecs
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Setup output_
13/04/09 11:54:34 INFO streaming.StreamJobPatch: Post Process Args
13/04/09 11:54:34 INFO streaming.MongoStreamJob: Args processed.
13/04/09 11:54:36 INFO io.MongoIdentifierResolver: Resolving: bson
13/04/09 11:54:36 INFO io.MongoIdentifierResolver: Resolving: bson
13/04/09 11:54:36 INFO io.MongoIdentifierResolver: Resolving: bson
13/04/09 11:54:36 INFO io.MongoIdentifierResolver: Resolving: bson
**Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/filecache/DistributedCache**
at org.apache.hadoop.streaming.StreamJob.setJobConf(StreamJob.java:959)
at com.mongodb.hadoop.streaming.MongoStreamJob.run(MongoStreamJob.java:36)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
at com.mongodb.hadoop.streaming.MongoStreamJob.main(MongoStreamJob.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:208)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.filecache.DistributedCache
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 10 more
If anyone could shed some light it would be a big help.
Full info:
As far as I can tell I needed to get the following four things to work:
- Install and test hadoop
- Install and test hadoop streaming with python
- Install and test mongo-hadoop
- Install and test mongo-hadoop streaming with python
So the short of it is I've got everything working up to the fourth step. Using (https://github.com/danielpoe/cloudera) i've got cloudera 4 installed
- Using chef recipe cloudera 4 has been installed and is up and running and tested
- Using michael nolls blog tutorials, tested hadoop streaming with python successfully
- Using the docs at mongodb.org was able to run both treasury and ufo examples (build cdh4 in build.sbt)
- Have downloaded 1.5 hours worth of twitter data using the readme for the twitter example in streaming/examples and also tried the treasury example.
sudo pip install pymongo_hadoop
– Conor